With Docker, you can easily create, run, manage, and share containers both on your computer/laptop and in the cloud.
There are two ways to use Docker:
- By installing and using the Docker Engine from a terminal. There are no costs involved.
- Through the Docker Desktop application. This comes with a GUI and has both free and paid licenses.
Both options are suitable for using Docker. It is mainly important to ask yourself whether you prefer to work from a terminal or not. Please note: For both options, you must first install the Docker package repository.
In this tutorial, we show you how to install the Docker Desktop application and Docker Daemon on a computer/laptop with a Linux distribution.
System Requirements
To use Docker in Linux, your computer/laptop must meet the following system requirements (minus the KVM/QEMU requirement if you install the Docker Engine):
- 64-bit operating system with systemd init system
- Support for KVM virtualization.
- QEMU 5.2 or newer (the newer the better).
- CPU support for virtualization.
- 4 GB of RAM.
- For Docker Desktop: Gnome, KDE, or MATE Desktop. In the case of Gnome with support for tray icons, for example via the AppIndicator extension.
- File sharing enabled.
Installing the Docker Package Repository
Regardless of whether you want to install the command-line daemon or Docker Desktop, you need the Docker package repository. You can install this using the steps below.
Step 1
First, update your operating system:
Ubuntu / Debian:
sudo apt -y update && sudo apt -y upgrade
CentOS / AlmaLinux / Rocky Linux:
sudo dnf -y install dnf-plugins-core sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
Step 2
Next, install Docker's package repository and dependencies (note the scrollbar):
Ubuntu:
With these commands, you install the packages needed to use an HTTPS repository, add Docker's GPG keys, and then the repository itself.
sudo apt-get install ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
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
sudo apt -y update
Are you getting an error message after the last command? This is usually due to incorrect permissions on docker.gpg. In that case, use these commands:
sudo chmod a+r /etc/apt/keyrings/docker.gpg sudo apt -y update
Debian:
With these commands, you install the packages needed to use an HTTPS repository, add Docker's GPG keys, and then the repository itself.
sudo apt-get install ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt -y update
Are you getting an error message after the last command? This is usually due to incorrect permissions on docker.gpg. In that case, use these commands:
sudo chmod a+r /etc/apt/keyrings/docker.gpg sudo apt -y update
CentOS / AlmaLinux / Rocky Linux:
sudo dnf -y install dnf-plugins-core sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Installing Docker Engine
After installing the Docker repository, installing and starting Docker Engine is relatively simple:
Ubuntu/Debian:
sudo apt -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin
CentOS/AlmaLinux/Rocky Linux:
sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin sudo systemctl start docker
That's it! You can now test the operation directly with the command:
sudo docker run hello-world
Installing Docker Desktop
The Docker Desktop installation is relatively simple from this point on and is done as follows:
Step 1
Download the Docker package for your operating system.
-
Ubuntu/Debian:
wget
desktop.docker.com/linux/main/amd64/docker-desktop-4.15.0-amd64.deb -
CentOS/AlmaLinux/Rocky Linux:
wget
desktop.docker.com/linux/main/amd64/docker-desktop-4.15.0-x86_64.rpm
Docker does not provide an option to download the latest version, only specific versions. The download link above is from December 15, 2022. You can find the most up-to-date version here for Ubuntu, Debian, CentOS, AlmaLinux, and Rocky Linux under 'DEB package' and 'RPM package' respectively.
Step 2
Install the Docker Desktop package that you just downloaded (adjust the version if you have downloaded a newer version):
Ubuntu/Debian:
sudo apt -y update sudo apt -y install ./docker-desktop-4.15.0-amd64.deb
CentOS/AlmaLinux/Rocky Linux:
sudo dnf -y install docker-desktop-4.15.0-x86_64.rpm
The installation of Docker Desktop is now complete. You can start Docker Desktop from the Applications menu.