Reputation: 2555
I need to install a very recent version of CMake on top of a jenkins Docker container. My Dockerfile looks like this:
FROM jenkins/jenkins:lts
# Install required plugins
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt
# Install CMake
RUN mkdir $JENKINS_HOME/cmake
RUN curl -L https://github.com/Kitware/CMake/releases/download/v3.13.1/cmake-3.13.1-Linux-x86_64.tar.gz | tar --strip-components=1 -xz -C $JENKINS_HOME/cmake
When I start the FROM
container interactive ($ docker run -it jenkins/jenkins:lts bash
) I am able to install CMake to $JENKINS_HOME/cmake
.
$ docker run -it jenkins/jenkins:lts bash
$ mkdir $JENKINS_HOME/cmake
$ curl -L https://github.com/Kitware/CMake/releases/download/v3.13.1/cmake-3.13.1-Linux-x86_64.tar.gz | tar --strip-components=1 -xz -C $JENKINS_HOME/cmake
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 620 0 620 0 0 826 0 --:--:-- --:--:-- --:--:-- 826
100 36.6M 100 36.6M 0 0 5485k 0 0:00:06 0:00:06 --:--:-- 7581k
$ ls $JENKINS_HOME/cmake
However, when I try to build that image using docker build
, the build fails:
...
Step 5/7 : RUN mkdir $JENKINS_HOME/cmake
---> Running in 6e8b914f2264
Removing intermediate container 6e8b914f2264
---> 24a75881d500
Step 6/7 : RUN curl -L https://github.com/Kitware/CMake/releases/download/v3.13.1/cmake-3.13.1-Linux-x86_64.tar.gz | tar --strip-components=1 -xz -C $JENKINS_HOME/cmake
---> Running in d1759df1fbdb
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 620 0 620 0 0 988 0 --:--:-- --:--:-- --:--:-- 988
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0tar: /var/jenkins_home/cmake: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
0 36.6M 0 50724 0 0 35123 0 0:18:13 0:00:01 0:18:12 82077
curl: (23) Failed writing body (2500 != 16360)
Running whoami
from within the Dockerfile and from within the interactive session, both yields jenkins
.
What is the main difference between both installation approaches and how can I install the latest CMake binaries using docker build
?
Upvotes: 3
Views: 4711
Reputation: 1007
Take a look here it's a Dockerfile from gcc
that installs the latest version of cmake
, this is its content:
FROM gcc:5
RUN wget https://github.com/Kitware/CMake/releases/download/v3.17.2/cmake-3.17.2-Linux-x86_64.sh \
-q -O /tmp/cmake-install.sh \
&& chmod u+x /tmp/cmake-install.sh \
&& mkdir /usr/bin/cmake \
&& /tmp/cmake-install.sh --skip-license --prefix=/usr/bin/cmake \
&& rm /tmp/cmake-install.sh
ENV PATH="/usr/bin/cmake/bin:${PATH}"
I was looking for a solution to build XGboost for GPU usage inside a Docker and needed a cmake
with the version above 3.12. This installation method works for me.
Upvotes: 3