Docker lets you create, deploy and run applications in isolated containers, keeping development, testing and production environments consistent. This guide explains how to install Docker on the main Linux families and which post-installation settings are useful straight away.
In this article
Install Docker on Ubuntu and Debian distributions
Docker Engine runs natively on Linux, without an additional virtualization layer, which provides better container performance. On Debian- or Ubuntu-based distributions, start by removing conflicting packages that could interfere with the installation.
sudo apt remove docker.io docker-compose docker-doc podman-docker containerd runc
Once the system is clean, prepare the package manager by installing the dependencies required to add new repositories securely.
sudo apt update && sudo apt install -y ca-certificates curl gnupg
For security, add Docker’s official GPG key so the integrity of downloaded packages can be verified. For Debian, configure the keyring with these commands. Ubuntu users only need to replace debian with ubuntu in the repository address.
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
(Note: for Ubuntu, replace debian with ubuntu in the URL.)
With the key in place, register the Docker repository with APT so the system can locate the required binaries.
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
To finish, refresh the package indexes and install the components required by Docker Engine, including the build tools and Docker Compose plugin.
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
The procedures described for Ubuntu and Debian also work on WSL (Windows Subsystem for Linux).
Install Docker on Rocky Linux and RHEL distributions
If you use an RHEL- or Rocky Linux-based distribution, the procedure is slightly different because it uses the DNF package manager. Start by removing any existing or conflicting container software to ensure a clean installation.
sudo dnf remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine podman runc
Once the environment is clean, install the repository-management plugin and configure Docker’s official repository to access recent engine versions.
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
Finally, install Docker Engine and its plugins, then enable and start the service so that it launches automatically with the system.
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl start docker
sudo systemctl enable docker
Configure Docker on Linux after installation
Docker commands require superuser privileges by default. You can make everyday use easier by adding your account to the Docker group.
sudo usermod -aG docker $USER
After this change, refresh your permissions by running newgrp docker or by closing your current session and signing in again. Remember that membership of this group gives your user privileges equivalent to the system administrator. For stronger isolation, consider rootless mode.
Configure the Docker daemon for production
To stop log files from filling your storage unnecessarily, customize the Docker daemon. Create or edit /etc/docker/daemon.json with the following content to limit log size and file count.
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}
After saving the file, restart the Docker service to apply the new limits immediately.
sudo systemctl restart docker
Don’t let the algorithm decide for you
Add Assistouest to your preferred sources on Google so you can find our guides faster when you search for an IT solution.
Make sure Docker is configured correctly
After installation, verify that the environment works. Run the official test container to validate the configuration immediately.
docker run hello-world
If the terminal displays “Hello from Docker!”, your Docker engine is installed and working. If there is a connection problem, check the service status to identify the cause.
systemctl status docker
You can also use a more detailed inspection command to view the daemon status, allocated resources and storage drivers currently used by the system.
docker info
An error occurred. Please try again in a moment.