How to Install Docker on Ubuntu 20.04

Docker is a popular platform for developing and running applications in containers. In this tutorial, we will show you how to install Docker on Ubuntu 20.04.

3 mins read

0 views

Not using Ubuntu 20.04?

Choose a different version or distribution.

Prerequisites:

  • A host running Ubuntu 20.04
  • A non-root user with sudo privileges (optional)

Step 1: Update the package list 

Before installing any new software, it's always a good idea to update the package list:

sudo apt update

Step 2: Install Docker

Once the package list is updated, you can install Docker by running the following command:

sudo apt install docker.io

This command installs the latest version of Docker available in the Ubuntu 20.04 repositories.

Step 3: Verify the installation 

After Docker is installed, you can verify the installation by running the following command:

docker --version

This command should output the version number of Docker that was just installed.

Step 4: Manage Docker as a non-root user (optional)

By default, the Docker daemon runs as the root user. This can be a security risk, so it's recommended to create a non-root user and add it to the "docker" group to manage Docker.

To create a new user, run the following command:

sudo adduser username

Replace "username" with the name of the user you want to create.

Next, add the user to the "docker" group:

sudo usermod -aG docker username

Replace "username" with the name of the user you created in the previous step.

Finally, log out and log back in as the new user for the changes to take effect.

Conclusion

In this tutorial, we showed you how to install Docker on Ubuntu 20.04. Docker is now ready to use on your server. You can start running containers by pulling images from Docker Hub or by building your own images.