Upgrade Docker Engine to Specific Version

I always recommend upgrading Docker Engine to a specific version that matches the rest of your infrastructure. For example if you are running the latest Amazon ECS-optimized AMI (currently amzn-ami-2016.09.d-amazon-ecs-optimized) — it contains Docker Engine 1.12.6. This writeup will show you exactly how to match that version. The steps are specific to Ubuntu 14.04.3 LTS.

1. Update package information

This is to ensure that APT works with the https method, and that CA certificates are installed:

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates

2. Add the new GPG key

FYI: This commands downloads the key with the ID 58118E89F3A912897C070ADBF76221572C52609D from the keyserver hkp://ha.pool.sks-keyservers.net:80 and adds it to the adv keychain. For more info, see the output of man apt-key.

sudo apt-key adv \
--keyserver hkp://ha.pool.sks-keyservers.net:80 \
--recv-keys 58118E89F3A912897C070ADBF76221572C52609D

3. Add specific repo for your distro to docker.list

FYI available repos:

Ubuntu version Repository
Precise 12.04 (LTS) deb https://apt.dockerproject.org/repo ubuntu-precise main
Trusty 14.04 (LTS) deb https://apt.dockerproject.org/repo ubuntu-trusty main
Wily 15.10 deb https://apt.dockerproject.org/repo ubuntu-wily main
Xenial 16.04 (LTS) deb https://apt.dockerproject.org/repo ubuntu-xenial main

So in our case:

mkdir -p /etc/apt/sources.list.d
echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list

4. Update the APT package index

sudo apt-get update

5. Verify that APT is pulling from the right repository

FYI: When you run the following command, an entry is returned for each version of Docker that is available for you to install. Each entry should have the URL https://apt.dockerproject.org/repo/. The version currently installed is marked with ***.

apt-cache policy docker-engine

6. Install the linux-image-extra-* kernel packages

FYI: For Ubuntu Trusty, Wily, and Xenial, install the linux-image-extra-* kernel packages, which allows you use the aufs storage driver.

sudo apt-get update
sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual

7. Finally Install a specific version of Docker Engine

7.1 List all available versions using apt-cache madison

apt-cache madison docker-engine

Example:

ubuntu@dev01:~$ apt-cache madison docker-engine
docker-engine | 1.12.6-0~ubuntu-trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
docker-engine | 1.12.5-0~ubuntu-trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
docker-engine | 1.12.4-0~ubuntu-trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
docker-engine | 1.12.3-0~trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
docker-engine | 1.12.2-0~trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
docker-engine | 1.12.1-0~trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
docker-engine | 1.12.0-0~trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages

7.2 Install docker-engine 1.12.6

FYI: If you already have a newer version installed, you will be prompted to downgrade Docker. Otherwise, the specific version will be installed.

sudo apt-get install docker-engine=1.12.6-0~ubuntu-trusty

8. Start the docker daemon

sudo service docker start

9. Verify that docker is installed correctly by running the hello-world image

sudo docker run hello-world

Based on: https://docs.docker.com/engine/installation/linux/ubuntulinux/

End.