Reputation: 8062
I am having trouble pinning the version of python and nodejs in a ubuntu based docker container.
The reason I am having difficulty is because the package versions available in the container change depending on the host.
I want to specify in the Dockerfile which versions of the python and nodejs debian packages by adding the following command:
RUN apt-get -y install "python=2.7.5-5ubuntu3" build-essential "nodejs=6.1.0-1nodesource1~trusty1" vim jq
I determined those version string by running some apt-cache madison
commands from within the ubuntu container running locally on my OSX el-capitan laptop. Everything works. When I try to build that same container in a CI environment running on an Amazon Linux instance it fails, because the named versions are not available.
Here is some output that shows exactly what is going on.
OSX El Capitan (via the docker-machine VBOX wrapper)
$ uname -a
Darwin Kyles-MacBook-Pro.local 15.3.0 Darwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64 x86_64
$ # now get into the container
$ docker exec -it named_container bash
root@79a839297d7e:/src# apt-cache madison nodejs
nodejs | 6.1.0-1nodesource1~trusty1 | https://deb.nodesource.com/node_6.x/ trusty/main amd64 Packages
nodejs | 0.10.25~dfsg2-2ubuntu1 | http://archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages
nodejs | 0.10.25~dfsg2-2ubuntu1 | http://archive.ubuntu.com/ubuntu/ trusty/universe Sources
nodejs | 6.1.0-1nodesource1~trusty1 | https://deb.nodesource.com/node_6.x/ trusty/main Sources
root@79a839297d7e:/src# apt-cache madison python
python | 2.7.5-5ubuntu3 | http://archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
python-defaults | 2.7.5-5ubuntu3 | http://archive.ubuntu.com/ubuntu/ trusty/main Sources
Same sequence in the CI environment - On AMI Linux :
$ uname -a
Linux ip-10-250-160-248 4.4.8-20.46.amzn1.x86_64 #1 SMP Wed Apr 27 19:28:52 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ # now get into the container
$ docker exec -it named_container bash
root@8344a5f311fe:/src# apt-cache madison nodejs
nodejs | 6.1.0-1nodesource1~xenial1 | https://deb.nodesource.com/node_6.x xenial/main amd64 Packages
nodejs | 4.2.6~dfsg-1ubuntu4 | http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages
nodejs | 4.2.6~dfsg-1ubuntu4 | http://archive.ubuntu.com/ubuntu xenial/universe Sources
nodejs | 6.1.0-1nodesource1~xenial1 | https://deb.nodesource.com/node_6.x xenial/main Sources
$ root@8344a5f311fe:/src# apt-cache madison python
python | 2.7.11-1 | http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages
python-defaults | 2.7.11-1 | http://archive.ubuntu.com/ubuntu xenial/main Sources
Here is the start of the Dockerfile, I changed the ENTRYPOINT and CMD as they are not relevant to this question
FROM ubuntu
MAINTAINER Kyle Zeeuwen
RUN apt-get update
RUN apt-get -y install curl
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
RUN apt-get -y install "python=2.7.5-5ubuntu3" build-essential "nodejs=6.1.0-1nodesource1~trusty1" vim jq
CMD ["sleep", "3600"]
So my questions:
What do I need to change to reliably set the python and nodejs version such that the docker container build will work in a range of host environments including both OSX and Linux AMI
What is going on that would make Ubuntu report different distros ?
Upvotes: 1
Views: 2194
Reputation: 3364
There are two possible reasons why the versions don't match:
docker pull ubuntu
before building, or build with the additional --pull
flag.apt-get update
step is cached and the cache is older on one machine than on the other. You should never run apt-get update
without any other command, because the cache will never be invalidated. Instead, do RUN apt-get update && apt-get -y install curl
. You can also run docker build --no-cache
to make sure you don't use any cache.In short: docker build --pull --no-cache
should fix your issue, but you should also adapt your Dockerfile as explained above.
Upvotes: 4