How To Install specific Docker version on Linux Machine.

To install Docker in most ways on Linux machine is possible by simple way.

curl -SsL https://get.docker.com | bash

But you may need in some cases to install specific docker version as per your requirements.

Here are some steps do so to install on most Linux Operating Systems.

On Ubuntu Based Distros.

For Latest Docker CE Versions

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

For Older Docker Versions CE.

curl -fsSL https://apt.dockerproject.org/gpg | sudo apt-key add -
sudo apt-add-repository "deb https://apt.dockerproject.org/repo ubuntu-$(lsb_release -cs) main"
sudo apt-get update

On Debian Based Distros

For Latest Docker CE Versions

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

For Older Docker Versions CE.

curl -fsSL https://apt.dockerproject.org/gpg | sudo apt-key add -
sudo apt-add-repository "deb https://apt.dockerproject.org/repo debian-$(lsb_release -cs) main"
sudo apt-get update

Now to install specific Docker versions on Ubuntu/Debian

For Latest Docker CE Versions

sudo apt-cache policy docker-ce
sudo apt-get install docker-ce=17.06.0~ce-0~ubuntu
or
sudo apt-get install docker-ce=17.06.0~ce-0~debian

For Older Docker Versions

sudo apt-cache policy docker-engine
sudo apt-get install docker-engine=1.13.1-0~ubuntu-xenial
or
sudo apt-get install docker-engine=1.13.1-0~debian-jessie

On Centos

For Docker CE Versions

sudo curl -SsL https://download.docker.com/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo

For Older Docker Versions

sudo tee /etc/yum.repos.d/docker.repo <<-’EOF’
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF

On Fedora

For Docker CE Versions

sudo curl -SsL https://download.docker.com/linux/fedora/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo

For Older Docker Versions

sudo tee /etc/yum.repos.d/docker.repo <<EOF
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/fedora/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF

Now to Install specific Docker versions on Centos/Fedora

For Latest Docker CE versions (≥17.06.0 CE)

sudo yum --showduplicates list docker-ce
sudo yum install docker-ce-17.06.0.ce-1.el7.centos
or
sudo yum install docker-ce-17.06.0.ce-1.fc25

For Older Docker versions (< 17.06.0 CE)

sudo yum --showduplicates list docker-engine
sudo yum install docker-engine-1.13.1-1.el7.centos
or
sudo yum install docker-engine-1.13.1-1.fc25

Thats All Folks. Go on install your choosen one :)