Docker is a fairly popular technology in today’s sysadmin. It is logical to think because it means a complete change in the way images and applications are distributed. In addition to all this, you can get the most out of many server-based Linux distributions. Therefore, learning about this technology is vital in the modern world. Therefore, in this post, you will learn how to install Docker on Ubuntu 20.04 / Debian 10. There are several premium versions, but in this case, we will use the community version which is more than enough for many cases.
Docker on the “new” world
Before Docker, the basic way to distribute applications on a server was through a virtual machine. I explain, if you developed an application that required a certain library in Debian 8 and you had to deploy it on a server, the most logical solution was to create a virtual machine with Debian 8. This was a small problem, having a virtual machine for one or two applications is not adequate. On the other hand, the server had to move several systems at once.
Now with Docker, you can “package” that application and its dependencies in the form of a container. These containers are distributed in the form of images that are interpreted by Docker on the server and can run independently of the system where it was built.
Likewise, Docker has port and volume isolation to increase security and integrity between the image and the host system.
Now, we are going to install Docker on Ubuntu 20.04 / Debian 10.
Install Docker on Ubuntu 20.04 / Debian 10
To perform this tutorial, it is necessary to have a user who has access to sudo or to have the password of the root user. Remember that we are going to do an installation.
1.- Add the Docker Repository
The easiest and safest way to install Docker on Ubuntu 20.04 / Debian 10 is to use the official Docker repository. This way, we will save time but we will also have Docker updated in an easy and secure way. So this is the officially recommended option.
Before adding the repository, first, you have to install some necessary packages. In a terminal session, run the following command:
:~$ sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common
The next step is to add the official GPG key to the repository. This ensures that downloaded packages are not compromised.
For Debian 10:
:~$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - OK
For Ubuntu 20.04:
:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - Ok
Using this repository you can install the test and nightly versions. However, we will use the stable channel to perform the installation.
For Debian 10:
:~$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian/ $(lsb_release -cs) stable"
For Ubuntu 20.04:
:~$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu/ $(lsb_release -cs) stable"
2.- Install Docker CE on Ubuntu 20.04 / Debian 10
Now that the Docker repository is added correctly, we will be able to update the APT cache.
:~$ sudo apt update
Now, using the following command we can install Docker.
:~$ sudo apt install docker-ce docker-ce-cli containerd.io
Note: If you have several Docker repositories enabled APT will always choose the newest version and this is a stability problem because It would prefer a beta version to a stable one.
3.- Test the Docker installation
First, we verify that the Docker service is correctly started with this command:
:~$ sudo systemctl start docker
If you want Docker starts at the booting:
:~$ sudo systemctl enable docker
Next, check the service status:
:~$ sudo systemctl status docker
As you can see, the Docker service is working properly.
Finally, run the docker
:~$ sudo docker run hello-world
So, Docker is ready for the action.
Docker’s technology is a wonder if you work with large-scale servers. Its practicality when depleting applications makes it an alternative to virtual machines. And now you have learned to install it on Ubuntu 20.04 / Debian 10.
So, please share this post with your friends and join our Telegram channel.