How can I install a specific version of the docker engine

How can I install a specific version of docker, e.g. 1.6.2?
The docker docs say to install on Ubuntu, use the following command:

wget -qO- https://get.docker.com/ | sh

Looking at the script, it basically adds docker to the sources list then does

apt-get install -y -q lxc-docker

which installs the latest version.
I tried replacing lxc-docker in the script with lxc-docker=1.6.2 but it says it can’t find that version. On inspecting the available versions in the archive using

apt-cache madison lxc-docker

it only returns the following:

lxc-docker |      1.7.0 | https://get.docker.com/ubuntu/ docker/main amd64 Packages

Is there a reliable method I can use to install an older version?
Thanks!

1 Like

I worked it out - if you want to install a specific version of docker, you can use the following:

wget -qO- https://get.docker.com/ | sed 's/lxc-docker/lxc-docker-1.6.2/' | sh

Replace 1.6.2 with the version you want.

I have added docker repository to sources.list:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
sudo echo “deb https://get.docker.io/ubuntu docker main” > /etc/apt/sources.list.d/docker.list

sudo apt-get update

List all available versions:
sudo apt-cache showpkg lxc-docker

Install 1.6.2 (or any of list above):
sudo apt-get install lxc-docker-1.6.2=1.6.2

Lock lxc-docker to this version (not updated on apt-get update):
sudo apt-mark hold lxc-docker

Unlock for installing latest version:
sudo apt-mark unhold lxc-docker
sudo apt-get update
sudo apt-get install lxc-docker

This does not seem to work anymore with docker v1.8.

I’d be very interested if somebody figured out to install docker 1.6.x or 1.7.x versions including dependencies, that still works after 1.8 was released.

Found a way that works at least for 1.7.X versions and above using the deb repository at:
https://apt.dockerproject.org/repo/pool/main/d/docker-engine

Installing docker now using:

wget -O docker.deb https://apt.dockerproject.org/repo/pool/main/d/docker-engine/docker-engine_1.7.1-0~trusty_amd64.deb 
sudo dpkg -i docker.deb

How to Install Docker Engine 1.6.2

  1. Download the repository key with:

    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9

  2. Then setup the repository:

    $ sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list" $ sudo apt-get update $ sudo apt-get install lxc-docker-1.6.2

  3. Run docker as non-sudo:

    $ sudo usermod -a -G docker $USER $ exit

Reference:
http://www.ubuntuupdates.org/ppa/docker?dist=docker

1 Like

For versions after 1.7; (sometimes I find you need a 1.7.1 client to push/pull from a 1.8+ private private registry in a docker container mapping external disks for persistence)

apt-cache showpkg docker-engine
Package: docker-engine
Versions:
Provides:
1.8.3-0~trusty -
1.8.2-0~trusty -
1.8.1-0~trusty -
1.8.0-0~trusty -
1.7.1-0~trusty -
1.7.0-0~trusty -
.
.
apt-get install docker-engine=1.7.1-0~trusty

At time of writing (just after 1.9.0 release), this works best on ubuntu trusty:

apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
mkdir -p /etc/apt/sources.list.d
echo deb https://apt.dockerproject.org/repo ubuntu-trusty main > /etc/apt/sources.list.d/docker.list
apt-get update;
apt-get install -y -q docker-engine=1.x.x~

In my case, with ansible there are modules for all of these things, so it can fit nicely into a playbook :-).

As Docker Introduces two different flavors (CE and EE) the best and easy way of installing Docker on any system. please run the below command and you do not have to do any thing.

wget -qO- https://get.docker.com/ | sh

if you want to install a specific version of a docker, you can run below command to find what all version of docker is present.

apt-cache madison docker-ce #(for ubuntu)
yum list docker-ce.x86_64  --showduplicates | sort -r #(for centos)

then select the proper version and place it in below command.

wget -qO- https://get.docker.com/ | sed 's/docker-ce/docker-ce=<DOCKER_VERSION/' | sh

In last versions of get.docker.com scripts you can also just set $VERSION environment variable before running the script.

The following article paints a pretty picture of how to install earlier versions from the command line:
How To Install specific Docker version on Linux Machine.
:grinning::grinning::grinning: