Installing Docker on Ubuntu Server

What is Docker?

According to Wikipedia Docker is a set of platform as a service products that uses OS-level virtualization to deliver software in packages called containers.

Containers are isolated from each other and contain their own software and configuration files. Containers are able to communitcate through private networks setup by docker.

Why put it on your server?

Installing Docker and configuring containers to run on an Ubuntu server can greatly simplify the task of setting up and maintaining the various software and services you may wish to run on your sever.

There is an emense collection of pre-built containers that you can use with docker for everything from hosting a simple web server to deploying complex microservices and more.

Installation

Now that we've covered the what and why, it's time to actaully get started with the installation. For the purpose of this post, we'll assume that you have a vanilla installation of UbuntuServer 18.04.4 LTS that you currently have SSH access to.

Docker exists in the standard repositorys. It is possible to add the offical Docker repository to your sources list, but unless you have a particular need to do so, I find that it's simpler and easier to use the one available in the standard repository.

First things first:

sudo apt update && sudo apt upgrade -y

Then install Docker:

sudo apt install docker.io

If you plan to use docker-compose to configure and run multiple containers at one, you will need to install that seperatley:

sudo apt install docker-compose

Next we should start Docker:

sudo systemctl start docker

Once that is all done, you can optionally configure Docker to start on boot:

sudo systemctl enable docker

To work with docker without having to use sudo you should add yourself to the docker group:

sudo usermod -aG docker <your user name>

In order for group assignments to take effect you may need to log out and back in to your server before continuing.

And you should be able to check the Docker version without any errors appearing in the terminal:

docker --version

At the time of writing the lastest docker version was

Docker version 19.03.6, build 369ce74a3c