# How to install Docker on Ubuntu 20.04 in 4 simple steps

You can use the **terminal** to install the popular virtualization software [Docker](https://www.ionos.com/digitalguide/server/know-how/what-is-docker/ "What is 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](https://www.ionos.com/digitalguide/server/know-how/what-is-ram/ "What is RAM?")
- 64-bit kernel and CPU support for virtualization
- KVM virtualization 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](https://www.ionos.com/digitalguide/server/know-how/ubuntu-the-linux-system-for-everyone/ "Ubuntu: The Linux system for everyone") 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](https://www.ionos.com/cloud/cloud-servers "IONOS Cloud Server") gives you the benefit of **virtualized server resources** and per-minute billing. Similar to a cloud server, a [vServer](https://www.ionos.com/servers/vps "IONOS vServer") also provides virtualized resources that can be **scaled at any time**. Billing involves a fixed monthly price. A [dedicated server](https://www.ionos.com/servers/dedicated-servers "IONOS 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](https://www.ionos.com/digitalguide/server/configuration/linux-server-distributions/ "Linux Server Distributions") like Ubuntu 20.04.

Tip If you’re not satisfied with your Ubuntu version, you can also [install Docker on Ubuntu 22.04](https://www.ionos.com/digitalguide/server/configuration/install-docker-on-ubuntu-2204/). Different Linux distributions are also compatible with the virtualization software. For example, you can [install Docker on Debian 11](https://www.ionos.com/digitalguide/server/configuration/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:

<table>
  <thead>
    <tr>
      <th><strong>Scenario</strong></th>
      <th><strong>Recommended server plan</strong></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>A server to implement and develop your own projects.</td>
      <td>Cloud Server XL</td>
    </tr>
    <tr>
      <td>A server to deploy various applications to clients.</td>
      <td>VPS Linux L</td>
    </tr>
    <tr>
      <td>A server equipped with Ubuntu 20.04 and Docker for deploying virtual environments.</td>
      <td>VPS Linux XL</td>
    </tr>
  </tbody>
</table>

## 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:

```shell
sudo apt-get update
sudo apt-get upgrade
```

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:

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

### 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:

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

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

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

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

```shell
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
```

### 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:

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

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

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

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

```shell
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
```

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](https://www.ionos.com/digitalguide/server/know-how/docker-container/ "Docker container") and check if the installation was successful:

```shell
sudo docker run hello-world
```

After running the Docker installation and calling the “Hello World” container, your terminal should show the following output:

[![Image: Terminal output after running “docker run hello-world”](https://www.ionos.com/digitalguide/fileadmin/_processed_/8/e/csm_terminal-output-docker-run-hello-world_71b08accd1.webp "Terminal output after running “docker run hello-world”")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2023/terminal-output-docker-run-hello-world.png) 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:

```shell
sudo groupadd docker
```

#### Step 5.2: Add users to the group

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

```shell
sudo usermod -aG docker $USER
```

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](https://www.ionos.com/digitalguide/server/configuration/docker-on-windows-10/) and [Docker on Windows 11](https://www.ionos.com/digitalguide/server/configuration/docker-windows-11/).


This is a markdown version of: [https://www.ionos.com/digitalguide/server/configuration/install-docker-on-ubuntu-2004/](https://www.ionos.com/digitalguide/server/configuration/install-docker-on-ubuntu-2004/) for AI/LLM consumption.