Ubuntu 22.04 is the current LTS version of the famous Linux distribution, very useful for many applications. Installing Docker virtualization software is very easy on Ubuntu 22.04 in just a few steps.
Minimum System Requirements¶
For successful installation of Docker software, your Linux system with Ubuntu 22.04 must fulfill certain conditions. As Docker remains a popular standard software, especially in the field of software development, these requirements are easily accessible:
- 64-bit kernel and processor-supported virtualization;
- KVM virtualization support;
- QEMU from version 5.2, latest version recommended;
- Gnome, KDE or MATE desktop environment;
- min. 4 GB of RAM, especially if you want to install Docker on a virtual machine with Linux.
The right choice of Linux server¶
To install Docker on Ubuntu 22.04, a local computer or virtual machine is not necessarily required. A personal linux server can do the trick just fine for setting up a Docker environment. In this case, you have the choice between different types of servers.
As a general rule, a distinction is made between cloud server solutions and dedicated servers. The Cloud Server and Virtual Private Server (vServer) use Cloud technology. While the former is billed per minute based on usage, the vServer offers a choice of different monthly rates. What both server types have in common, however, is that you can adapt your server to your current needs at any time thanks to the evolutionary character of their resources.
The dedicated server also operates on a per-minute basis, but it does not use cloud technology. This is a provision of a specific dedicated enterprise hardware which meets the highest standard requirements for this type of system.
Whichever server you choose, none will impose a specific operating system on you and you are again free to choose. IONOS offers several common Linux distributions, but also Windows. In addition, the IONOS hardware guarantees you an excellent broadband connection of up to 400 MB/s and maximum availability at all times.
Comparison of server types and IONOS prices¶
Faced with the different types of servers, it is not always easy to see clearly. How to ask the right questions to know which server would be the most suitable for your use? To help you find your way around, consult the following summary table. He lists three types of uses among the most common to help you make your choice:
Use | Adapted server |
---|---|
Implement and develop your own projects: priority use development and test phases | XL Cloud Server |
Deploy different applications for your customers: priority use deployment | Cloud RAM Virtual Server L |
Deploy virtual environments with your server: priority use virtualization | Cloud RAM XL Virtual Server |
Not a fan of Ubuntu 22.04? No problem, you can also install Docker on Ubuntu 20.04. If you want to try something new, why not try another Linux distribution with virtualization software?
Docker on Ubuntu 22.04: step-by-step installation¶
Installing Docker on Ubuntu 22.04 can be done directly in the terminal. You will only need to know a few basic terminal commands.
Step 1: Preparing the System¶
First, you need to update your operating system. This is done quickly using the following two commands:
sudo apt-get update
sudo apt-get upgrade
Step 2: Remove obsolete files from Docker¶
If you have already used a beta or preview version of Docker, remove it before installing the virtualization software to avoid possible conflicts or unwanted effects.
sudo apt remove docker-desktop
rm -r $HOME/.docker/desktop
sudo rm /usr/local/bin/com.docker.cli
sudo apt purge docker-desktop
Step 3: Download the Docker repository¶
For installation, Docker goes through a repository that it registers in your system. To work with this repository, you first need to install the following packages:
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
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
A suitable command line in the terminal then allows you to set up the Docker repository:
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
Step 4: Install Docker Engine¶
Under Ubuntu 22.04, it is also possible to download Docker Engine directly in the terminal. For this, the command lines you need vary depending on whether you want to install a specific version of Docker, or simply the most recent version.
To download a specific version of Docker, first use the following command to get a list of all available versions:
apt-cache madison docker-ce | awk '{ print $3 }'
You just need to select one of the versions from the displayed list indicating it as VERSION_STRING. The installation is then done as follows:
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
The procedure is even simpler to install the most recent version of Docker:
apt-cache madison docker-ce | awk '{ print $3 }'
Step 5: Verify Installation¶
To see the installation was successful, Docker offers the possibility to launch a « Hello World » Docker container with the following terminal command line:
sudo docker run hello-world
If the installation was successful, the following output will be displayed:
Step 6 (optional): Run Docker as a non-root user¶
As you have seen with terminal commands, root rights are required to run Docker. This is why you must start all your commands with « sudo ». Launch Docker as as user without root privileges can be done provided you create a dedicated Docker group.
Step 6.1: creation of the “Docker” group¶
Create a group called « Docker » to include the relevant user profiles with the following command:
Step 6.2: adding profiles¶
A simple command line allows you to add to your Docker group all user profiles with Docker execution rights but without root privileges:
sudo usermod -aG docker $USER
The $USER string here replaces the name of the user to add, it’s up to you to replace it with the profiles concerned. To save changes, you will need to log out before logging in again. You can then access Docker as a user who is a member of the Docker group without having to go through sudo.