Docker is a container platform that has revolutionised the way developers build, test and deploy applications. This manual will explain how to install and use Docker on Ubuntu 20.04, allowing developers to quickly and easily create applications in any environment.
Before getting started with the Docker installation, you need to make sure that the following prerequisites are met:
A machine with Ubuntu 20.04 installed: Docker is compatible with Ubuntu 20.04, so you need 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 required. In addition, Docker images may need to be downloaded from the Internet to create containers.
To install Docker on Ubuntu 20.04, the following steps are required:
Before installing any package, it is recommended to upgrade the system. To do this, open a terminal and run the following command:
sudo apt update && sudo apt upgrade
To install Docker, run the following command in the terminal:
sudo apt install docker.io
info This command will download and install Docker on the system.
Once the installation is complete, you can verify that Docker has been successfully installed by running the following command:
info This command should display the version of Docker installed on the system.
To avoid running Docker commands with administrator permissions, you can add the current user to the Docker group. To do this, run the following command:
sudo usermod -aG docker $USER
info This command will add the current user to the Docker group.
For the changes to take effect, you need to reboot the system. To do this, run the following command:
info Once the system has rebooted, Docker is ready to be used.
It is important to note that if you are using a firewall on your system, you need to open port
2375 to allow Docker to communicate with the outside.
Once Docker is installed on Ubuntu 20.04, you can start using it to create and run containers. Here are some basic commands for working with Docker:
Before creating a container, you need to download an image. Images are templates that are used to create containers. To download an image, the following command must be executed:
docker pull nombre_de_la_imagen
For example, to download the Ubuntu image, run the following command:
docker pull ubuntu
Once you have downloaded the image, you can create a container from it. To create a container, run the following command:
docker run -it nombre_de_la_imagen
-it parameter indicates that you want to run the container in interactive mode. For example, to create an archive from the Ubuntu image, run the following command:
docker run -it ubuntu
To exit a container, the following command must be executed:
To list the running containers, run the following command:
To list all containers, including non-running containers, run the following command:
docker ps -a
To delete a container, the following command must be executed:
docker rm nombre_del_contenedor
For example, to delete a container named
my_container, you would run the following command:
docker rm my_container
To execute commands in a running container, the following command must be executed:
docker exec -it nombre_del_contenedor comando
For example, to execute the
ls command on a container named
my_container, the following command must be executed:
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.
Docker is an essential tool for any developer who wants to quickly and easily build, test, and deploy applications in any environment. With Docker, developers can create containers that contain all the dependencies and configurations necessary for an application to run consistently, saving time and reducing configuration errors.