7 C
Texas
angeloma
Senior Writer and partner

How to install Docker on Ubuntu 20.04 / Debian 10?

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.

- Advertisement -

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.

On the other hand, the server or computer must have SSH enabled. Although if you have installed Debian 10 Buster with our tutorial, it should already be working.

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

1.- Install some required package
1.- Install some required package

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

2.- Install Docker on Ubuntu 20.04 / Debian 10
2.- Install Docker on Ubuntu 20.04 / Debian 10

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

3.- Docker is running
3.- Docker is running

As you can see, the Docker service is working properly.

Finally, run the docker hello-world.

:~$ sudo docker run hello-world

4.- Docker Hello world
4.- Docker Hello world

So, Docker is ready for the action.

Conclusion

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.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

2 COMMENTS

  1. Excelente conteúdo, parabéns pelo trabalho.

    Só faltou uma letra “s” na linha: sudo sytemctl enable docker

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article