How to install Docker on Ubuntu 20.04 in 4 simple steps

You can use the terminal to install the popular virtualisation software Docker on Ubuntu 20.04 in just a few easy steps.

What are the requirements for installing Docker on Ubuntu 20.04?

Docker is a standard software and doesn’t require much of your Linux system:

  • At least 4 GB RAM
  • 64-bit kernel and CPU support for virtualisation
  • KVM virtualisation technology support
  • A desktop environment such as Gnome, KDE or MATE
  • QEMU from version 5.2, although using the current version is recommended

Which Linux server best fits your needs?

If you would rather install Ubuntu 20.04 and Docker on a server instead of on your local computer, you have different types of servers to choose from: dedicated servers, cloud servers and virtual private servers.

A cloud server gives you the benefit of virtualised server resources and per-minute billing. Similar to a cloud server, a vServer also provides virtualised resources that can be scaled at any time. Billing involves a fixed monthly price. A dedicated server provides dedicated hardware that can only be used by you. This model ensures maximum performance and is billed on a per-minute basis.

At IONOS, every server has an excellent broadband connection with up to 400 Mbps and the highest availability. You can choose between various operating systems, including popular Linux distributions like Ubuntu 20.04.

Tip

If you’re not satisfied with your Ubuntu version, you can also install Docker on Ubuntu 22.04. Different Linux distributions are also compatible with the virtualisation software. For example, you can install Docker on Debian 11 in just a few steps as well.

Which IONOS plan is right for you?

Which server is right for you depends on how you plan to use the server. We’ve provided three common usage scenarios for a Linux server with Docker to help you figure out which server is best for you:

Scenario Recommended server package
A server to implement and develop your own projects. Cloud Server XL
A server to deploy various applications to clients. VPS Linux L
A server equipped with Ubuntu 20.04 and Docker for deploying virtual environments. VPS Linux XL

How to install Docker on Ubuntu 20.04: step-by-step instructions

Step 1: prepare server

First, make sure that all packages and your system are up to date. To do this, enter the following commands in the terminal to update your system:

sudo apt-get update
sudo apt-get upgrade
shell

If you’ve already used a preview or beta version of Docker, you’ll need to remove it. Make sure to also remove any files that were created with a preview or beta version before you start installing Docker:

sudo apt remove docker-desktop
rm -r $HOME/.docker/desktop
sudo rm /usr/local/bin/com.docker.cli
sudo apt purge docker-desktop
shell

Step 2: add Docker repository

For both the installation of Docker and subsequent updates, you’ll first need to add a repository to your system. To do this, install the following packages:

sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release
shell

You can then add Docker’s GPG key to your system:

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
shell

Lastly, set up the Docker repository with the following command:

echo \
    "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
    $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
shell

Step 3: install Docker Engine

Now you can download Docker Engine onto Ubuntu 20.04 via the terminal. If you want to install the latest version of Docker, use the following command:

sudo apt-get install docker-ce dock ber-ce-cli containerd.io docker-compose-plugin
shell

If you’re thinking of installing a specific Docker version, start by listing the different versions available:

apt-cache madison docker-ce | awk '{ print $3 }'
shell

Then you can select one of the versions from the list and install it with the following command:

VERSION_STRING=5:20.10.13~3-0~ubuntu-jammy
sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-compose-plugin
shell

Make sure to specify the version that you want to install on your system.

Step 4: check if the installation was successful

After the installation, you can use the following command to start a ‘Hello World’ Docker container and check if the installation was successful:

sudo docker run hello-world
shell
Terminal output after running ‘docker run hello-world’
After running ‘docker run hello-world’, you should get a brief explanation of how Docker works.

Step 5 (optional): run Docker as a non-root user

To run Docker, you need root privileges. You can work around this by creating a new group named ‘docker’ on your system and adding the users who should have execute privileges for Docker to it.

Step 5.1: create Docker group

Create a group named ‘docker’ with the following command:

sudo groupadd docker
shell

Step 5.2: add users to the group

Add all users that you want to be able to run Docker using the following command:

sudo usermod -aG docker $USER
shell

Remember that $USER is just a placeholder and must be replaced with a user’s name. For the changes to take effect, you need to log out and then log back in. After this, you can access Docker without using sudo.

Tip

Using Windows, too? We have further manuals for installing Docker on Windows 10 and Docker on Windows 11.

Was this article helpful?
Page top