Install Docker
on Ubuntu 18.04 LTS

from Official Repository

By Benjamin Hobbs

So I have been wanting to create a private encrypted messenger service for quite sometime. Originally I was just going to install it on VM as a standalone server behind a Reverse Proxy server. However, that method of install proved to have some strange and quirky issues. I have decided to abandon that approach and use a docker container instead. Hopefully this way will work out better. Before I can get to that point though, I have to get a few prerequisites out of the way first.

The first order of business is to get docker installed. I have chosen to use the official repository over the docker package available from the Ubuntu repository. This will allow me to use the latest version of Docker.

Prerequisites

As usual before we install any packages it is always a good idea to make sure your system is updated:
sudo apt-get update
sudo apt-get upgrade
Before we can install Docker we need to install several packages first:
apt install apt-transport-https ca-certificates curl software-properties-common
Now we need to add the official Docker GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Once the GPG key has been added we can now activate the Docker Repository and update our ubuntu repository:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu  $(lsb_release -cs)  stable"
sudo apt update

The command “$(lsb_release –cs)” scans and returns the codename of your Ubuntu installation – in this case, Bionic. Also, the final word of the command – stable– is the type of Docker release.

Now it is time to install the latest version of docker:
sudo apt-get install docker-ce

If you are looking to install a previous version, we also have an optional method we can use in order to achieve this. Using the Docker Repositories allows us access to these version.

Installing a specific version of Docker (optional) Use this command to list all the previous versions:

apt-cache madison docker-ce

You should see this output or something similar to this:

 docker-ce | 5:19.03.1~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:19.03.0~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:18.09.8~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:18.09.7~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:18.09.6~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:18.09.5~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:18.09.4~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:18.09.3~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:18.09.2~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:18.09.1~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:18.09.0~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 18.06.3~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 18.06.2~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 18.06.1~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 18.06.0~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 18.03.1~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
After the system has returned an available version list we need to now enter in this command:
sudo apt-get install docker-ce=[version number]
sudo apt-get install docker-ce=18.06.1~ce~3-0~ubuntu

Conclusion:

You now have several different methods to install Docker. There are some great tools to help you manage your Docker Containers. Check out my blog on portainer and look for my instructional videos coming soon!