How to install docker specific version

Follow below step to install specific version of docker-ce and docker-ce-cli .

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update

Find the specific version of docker-ec and docker-ce-cli . Her in this example i am looking for 19.03

apt-cache policy docker-ce | grep 19
apt-cache policy docker-ce-cli | grep 19

From above command you will get list of docker version , copy respected version.

apt-get install docker-ce=5:19.03.14~3-0~ubuntu-bionic docker-ce-cli=5:19.03.14~3-0~ubuntu-bionic 

Got the answer from this github issue comment.

Summary of above commit:-

echo deb http://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list

apt-key adv --keyserver pgp.mit.edu --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9

apt-get update
apt-get install -y lxc-docker-1.3.3

If permission issue then use sudo as:

echo deb http://get.docker.com/ubuntu docker main | sudo tee /etc/apt/sources.list.d/docker.list

sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9

sudo apt-get update
sudo apt-get install -y lxc-docker-1.3.3

Bonus Tip:

Don't know which version? Then hit Tab after lxc-docker- as:

sudo apt-get install -y lxc-docker-<Hit Tab here>

to see list of available docker versions.


I find easier to check available versions with

sudo apt-cache policy docker-engine

and then install the one you want:

sudo  apt-get install docker-engine=1.7.1-0~trusty

It consists on simply following the instructions from docker docs https://docs.docker.com/engine/installation/ubuntulinux/, but selecting a particular version


How I did it on my laptop (btw https://get.docker.com/ubuntu/ not available anymore):

$ wget -qO- https://get.docker.com/ | sh      # install resources
$ apt-cache showpkg docker-engine             # show version which are available
$ apt-get install docker-engine=1.8.2-0~willy # install 1.8.2 version
$ sudo apt-mark hold docker-engine            # prevent upgrade on sys upgrade
$ docker version                              # check installed docker version