The famous Docker virtualization software can be easily installed on Ubuntu 20.04 via the terminal.
Docker on Ubuntu 20.04: minimum configuration¶
Docker is standard software that remains resource-efficient for your Linux system:
- min. 4 GB of RAM;
- 64-bit kernel and processor-supported virtualization;
- KVM virtualization support;
- Gnome, KDE or MATE desktop environment;
- QEMU from version 5.2, latest version recommended.
Choosing the right Linux server¶
If you want to install Ubuntu 20.04 and Docker on a server and not on your local computer, you can choose between different types of servers depending on how you are going to use it. As a general rule, a distinction is made between dedicated servers, cloud servers and VPS (virtual private servers).
A Cloud server allows you to benefit from virtualized server resources with per-minute billing. The vServer works according to a principle similar to that of the Cloud server by also making available virtualized resources and adjustable at any time, with fixed monthly billing. Finally, the operation of dedicated servers is slightly different: you have a equipment dedicated to exclusive use to guarantee you maximum performance, with billing by the minute.
IONOS guarantees you an excellent broadband connection (up to 400 MB/s) with maximum availability for each server. You can choose between different operating systems, including the most common Linux distributions, such as Ubuntu 20.04.
Fields of application and adapted IONOS tariffs¶
Choosing the most suitable server totally depends on usage what you want to do with it. To get the best overview of the different server prices, the following table summarizes three of the most common types of uses for a Linux server with Docker:
Use | Adapted server |
---|---|
Server for application development and testing: Choose your server to implement and develop your own projects. | XL Cloud Server |
Application Deployment: Deploy different applications for your customers with your Linux server. | Cloud RAM Virtual Server L |
Virtualization: Use your server with Ubuntu 20.04 and Docker to deploy virtual environments. | Cloud RAM XL Virtual Server |
Docker on Ubuntu 20.04: step-by-step installation procedure¶
Docker installs on your Linux system with Ubuntu 20.04 in just a few steps.
Step 1: Preparing the System¶
First, make sure you have the Last update system and all packages. To do this, enter the following commands in the terminal to update the system:
sudo apt-get update
sudo apt-get upgrade
shell
If you have already used a preview or beta version of Docker, delete it as well as all files created with this version before you can start installing Docker.
sudo apt remove docker-desktop
rm -r $HOME/.docker/desktop
sudo rm /usr/local/bin/com.docker.cli
sudo apt purge docker-desktop
shell
Step 2: Add a Docker repository¶
Both for the first installation of Docker and for its subsequent updates, add a dedicated repository to your system. To do this, you must first install the following packages:
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
shell
You can then add the GPG key from the official Docker repository to your system:
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
shell
Finally, you must set up the Docker repository with the following command line:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
shell
Step 3: Install Docker Engine¶
You can now download Docker Engine on Ubuntu 20.04 through the terminal. If you want to install the current version from Docker on your system, use the following command:
sudo apt-get install docker-ce dock ber-ce-cli containerd.io docker-compose-plugin
shell
If you are instead looking to install a specific version of Dockeryou can first request a list of the different versions available:
apt-cache madison docker-ce | awk '{ print $3 }'
shell
Then you just have to choose one of these versions and install it with the following command line:
VERSION_STRING=5:20.10.13~3-0~ubuntu-jammy
sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-compose-plugin
shell
Warning: in this case, be sure to indicate the version of the list that you want to install on your system as VERSION_STRING.
Step 4: Verify proper Docker installation on Ubuntu 20.04¶
Once the installation procedure is complete, you can use the following command line to launch a “Hello World” Docker container to verify that the installation was successful:
sudo docker run hello-world
shell
Once the Docker installation is complete and the “Hello World” container is launched, this is the output your terminal should show:
Step 5 (optional): Run Docker as a user without root privileges¶
To be able to run Docker, you must have the root privileges. However, it is possible to work around this by creating a new group called “docker” on your system and adding the users who are supposed to have execute rights for Docker to it.
Step 5.1: Create the Docker group¶
First create the “docker” group with the following command line:
sudo groupadd docker
shell
Step 5.2: Add users¶
Add all users who need to be able to run Docker to the group using the following command line:
sudo usermod -aG docker $USER
shell
In this example, $USER replaces the name of the desired user, it’s up to you to replace the string with the profile name. For the changes to take effect, you must then log out and then log in again. You can then access Docker without going through sudo.