How to install and use Docker on Ubuntu 20.04?

Updated on 2026-10-09 15:00:42 18 visits

Introduction

Docker is a container platform that has revolutionized the way developers create, test, and deploy applications. In this manual, it will be explained how to install and use Docker on Ubuntu 20.04, which will allow developers to create applications quickly and easily in any environment.

Prerequisites

Before starting the installation of Docker, it is necessary to ensure that the following prerequisites are met:

  • A machine with Ubuntu 20.04 installed: Docker is compatible with Ubuntu 20.04, so it is necessary to have a machine with this operating system installed.

  • Access to a user account with administrator permissions: To install Docker, administrator permissions are required.

  • Internet connection: To download and install Docker, a stable and fast internet connection is necessary. Additionally, it may be necessary to download Docker images from the internet to create containers.

Installing Docker on Ubuntu 20.04

To install Docker on Ubuntu 20.04, the following steps must be followed:

1. Update the system

Before installing any package, it is recommended to update the system. To do this, you should open a terminal and execute the following command:

sudo apt update && sudo apt upgrade

2. Install Docker

To install Docker, you should execute the following command in the terminal:

sudo apt install docker.io

info This command will download and install Docker on the system.

3. Verify the installation

Once the installation is complete, you can verify that Docker has been installed correctly by executing the following command:

docker --version

info This command should show the version of Docker installed on the system.

4. Add user to the Docker group

To avoid executing Docker commands with administrator permissions, you can add the current user to the Docker group. To do this, you should execute the following command:

sudo usermod -aG docker $USER

info This command will add the current user to the Docker group.

5. Restart the system

For the changes to take effect, it is necessary to restart the system. To do this, you should execute the following command:

sudo reboot

info Once the system has restarted, Docker will be ready to be used.

It is important to keep in mind that, if a firewall is used in the system, it is necessary to open port 2375 to allow Docker to communicate with the outside.

Using Docker

Once Docker is installed on Ubuntu 20.04, it can be started to be used to create and run containers. Below are some basic commands for working with Docker:

Download an image

Before creating a container, it is necessary to download an image. Images are templates used to create containers. To download an image, you should execute the following command:

docker pull image_name

For example, to download the Ubuntu image, you should execute the following command:

docker pull ubuntu

Create a container

Once the image is downloaded, a container can be created from it. To create a container, you should execute the following command:

docker run -it image_name

The -it parameter indicates that the container is to be run in interactive mode. For example, to create a container from the Ubuntu image, you should execute the following command:

docker run -it ubuntu

Exit a container

To exit a container, you should execute the following command:

exit

List running containers

To list running containers, you should execute the following command:

docker ps

List all containers

To list all containers, including those that are not running, you should execute the following command:

docker ps -a

Delete a container

To delete a container, you should execute the following command:

docker rm container_name

For example, to delete a container called my_container, you should execute the following command:

docker rm my_container

Execute commands in a container

To execute commands in a running container, you should execute the following command:

docker exec -it container_name command

For example, to execute the ls command in a container called my_container, you should execute the following command:

docker exec -it my_container ls

success With these basic commands, you can start working with Docker and take advantage of all its benefits to create, test, and deploy applications quickly and easily.

Conclusion

Docker is an essential tool for any developer who wishes to create, test, and deploy applications quickly and easily in any environment. With Docker, developers can create containers that contain all the necessary dependencies and configurations for an application to run consistently, which saves time and reduces configuration errors.