It has been brought to my attention that the way that I have been installing Docker in some of my previous posts, while it does work (and in my opinion is the easiest way to install) does not yield the latest version of Docker being installed.
Therefore, I thought I’d do a quick post on how to get the latest version installed (from the official repo), as usual, this is done on an Ubuntu 16.04 instance (in my case). Essentially this is going from the package called docker.io (outdated), to docker-ce.
Since you’re reading this, it means that I successfully upgraded the server running this blog to the latest version, so I am basing the following steps on already having the previous version installed as I outlined it in previous posts.
Let’s break this up into 3 sections:
- Preparing the system
- Uninstall the other versions (scary bit)
- Install the new version from the Repo
- Preparing the system:
First, we run
apt-get update followed by
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common. This install command will install all the packages required to allow apt to install using HTTPS to access the Docker Repo.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - which will add Docker’s GPG key to your system.
Now we will need to add the repository to install the new version of Docker from, using the command:
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
This adds the official docker repo for Ubuntu to the system (using the stable release channel), after which we need to re-run
apt-get update in order to re-populate the package index.
Now that we have everything prepared, we can start on the next step.
- Uninstalling the older Docker versions:
Pretty simple really, we just need to run:
sudo apt-get remove docker docker-engine docker.io which will remove the older packages entirely. Be warned, it is most likely that this will remove any running containers and services that you have (even though it didn’t for me).
- Install the new version from the Repo we added previously
Which we do using the following:
sudo apt-get install docker-ce
Once we have done all that, if we run
docker info on the system, we get the correct output, and it indicates:
Server Version: 17.06.2-ce - which means we are good to go! (17.06.2 is the latest stable version).
docker ps on the system now indicates the following:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d701c68f0108 httpd:latest "httpd-foreground" 10 minutes ago Up 10 minutes 80/tcp httpd.1.6jk8oww9y0rdcp4o292qyma0s b138fcd9f1e6 ghost:latest "docker-entrypoint..." 10 minutes ago Up 10 minutes 2368/tcp ghost.1.mwisj5qx78yhfpzjaxsofwr6l d115a811f7f6 traefik:latest "/traefik --web --..." 10 minutes ago Up 10 minutes 80/tcp traefik.1.miahkuz1g8r8josarrh0nonj2
As we can see, all my containers are still running! Which means everything is good to go. Yay!
A big advantage of doing this process, is that as new versions of Docker are released, we can simply install them from the official repo, quickly and easily, without the need to download any packages manually. How convenient!
Things to note:
Before anyone says it, yes, I backed up the configuration for ALL my containers before I did this process, including all the service create commands for my Ghost, Traefik and Httpd containers. This is highly advised, as the likelihood of losing your container configuration is pretty high with this process.
The offical Docker Docs, DO outline this process in more detail here, however I simply went through what I did in my situation and what worked for me.
As always, let me know any comments, feedback or suggestions on future posts.