In this manual, we will show you how to install and configure Docker on your own server. Following these simple steps, you can have Docker installed and fully functional in a few minutes, allowing you to launch containers or "compose" multiple container architectures.
This manual covers the installation of Docker for the distribution Ubuntu 18.04. The procedure will be very similar in later versions of Ubuntu and even for any distribution based on Debian. However, the steps detailed below will not work for distributions such as Red Hat, Fedora, CentOS, etc.
All the commands in this manual assume that they are executed with root permissions. Depending on the configuration of each system it may be necessary to precede them with "sudo".
First we will proceed to install the repositories as well as the necessary dependencies.
1. We update the list of packages
2. We make sure to establish connection with repositories through the HTTPS protocol
apt-get install apt-transport-https ca-certificates curl software-properties-common
The previous command will install the necessary dependencies to be able to add and work correctly with a repository through a secure connection.
3. Download and add the public key of the Docker repository
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
This key will allow us to verify the integrity of the files and the authenticity of the sender, avoiding in this way any type of spoofing of packages/files. This is a standard and common security measure.
4. We add the repository and update the list of packages
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
Attention: Note that the previous command includes the release name of the distribution. In this case, "bionic". In case this manual is used in other versions of Ubuntu or distributions derived from Ubuntu, it will be necessary to change this word to ensure compatibility.
Finally, we update the list of packages, thereby enabling the repository.
5. We install Docker through the package manager
apt-get install docker-ce
The package name "docker-ce" refers to the free version ("community edition") of Docker.
6. We test the installation by launching the "hello-world" container
docker container run hello-world
It is done!
If you have followed all the steps correctly, you will have successfully installed Docker on your Ubuntu server.