In this manual we will show you how to install and configure Docker on your own server. By following these simple steps you will be able to have Docker installed and fully functional in just a few minutes, allowing you to launch containers or "compose" multi-container architectures.
This manual covers the installation of Docker for the Ubuntu 18.04 distribution. The procedure will be very similar for later versions of Ubuntu and even for any Debian-based distribution. However, the steps detailed below will not work for distributions such as Red Hat, Fedora, CentOS, etc.
All 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. Update the package list
2. We ensure that we can establish connection with repositories through the HTTPS protocol.
apt-get install apt-transport-https ca-certificates curl software-properties-common
The above command will install the necessary dependencies to be able to add and work correctly with a repository through a secure connection.
3. We 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, thus avoiding any kind of packet / file spoofing. This is a standard and common security measure.
4. Add the repository and update the package list.
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 will update the list of packages, thus enabling the repository.
5. Install Docker using the package manager.
apt-get install docker-ce
The package name "docker-ce" refers to the free ("community edition") version of Docker.
6. We test the installation by launching the container "hello-world ".
docker container run hello-world
You are done!
If you have followed all the steps correctly, you have successfully installed Docker on your Ubuntu server.