Installing Docker on Linux Servers
Introduction
Docker Engine is an open-source platform for building and managing containers. It packages applications along with all their dependencies into lightweight, portable containers, ensuring consistent behavior across any server.
In this guide, we will install Docker Engine via the official Docker repository on Ubuntu, Debian, Fedora, and RHEL operating systems. We will also cover post-installation configuration, upgrading, and uninstallation.
Important note about firewalls
When Docker exposes container ports, those ports bypass ufw or firewalld rules. This means that even if you run ufw deny 8080, port 8080 exposed through Docker will still be accessible from the outside.
Docker is only compatible with iptables-nft and iptables-legacy. Firewall rules created with nft will not work on a system where Docker is installed.
More details: Docker and ufw (opens in a new tab)
Installing Docker Engine
- Ubuntu
- Debian
- Fedora
- RHEL
Installing Docker Engine on Ubuntu
OS requirements
To install Docker Engine, you need a 64-bit version of one of the following Ubuntu releases:
- Ubuntu Questing 25.10
- Ubuntu Noble 24.04 (LTS)
- Ubuntu Jammy 22.04 (LTS)
Supported architectures: x86_64 (amd64), armhf, arm64, s390x, ppc64le (ppc64el)
Docker is not officially supported on Ubuntu-based distributions such as Linux Mint (it may work, but is not guaranteed).
Uninstall old versions
Before installing the official version of Docker, you should remove any unofficial Docker packages that may be present on the system, as they can cause conflicts:
sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc podman-docker containerd runc | cut -f1)apt may report that none of these packages are installed — this is perfectly normal.
Images, containers, and volumes in /var/lib/docker/ are not automatically removed when Docker is uninstalled.
Install using the APT repository
1-> Add Docker's official GPG key and APT repository:
# Add Docker's official GPG key
sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add Docker repository to APT sources
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt updateWhat do these commands do?
- GPG key — verifies that downloaded packages genuinely come from Docker
- APT source — provides the
aptpackage manager with Docker's official repository URL ${UBUNTU_CODENAME:-$VERSION_CODENAME}— automatically detects your system's codename (e.g.,noble,jammy)
2-> Install Docker Engine and its components:
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -yWhere:
docker-ce— Docker Engine (the core engine)docker-ce-cli— Docker CLI (command-line interface)containerd.io— container runtimedocker-buildx-plugin— extended build capabilitiesdocker-compose-plugin— thedocker composecommand (for multi-container applications)
3-> Start Docker and verify it is running:
sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker4-> Verify that the installation was successful:
sudo docker run hello-worldThis command downloads a test image and runs it in a container. If you see the "Hello from Docker!" message on screen, everything is working correctly.
Post-installation configuration
After installing Docker, there are several important configurations to complete.
Running Docker without root
By default, Docker only works with root or sudo. To run Docker commands as a regular user, add your user to the docker group:
sudo usermod -aG docker $USERFor this change to take effect, you need to open a new terminal session or log out and log back in. To apply it immediately:
newgrp dockerThen verify that it works without sudo:
docker run hello-worldVerifying the Docker installation
Run the DevOps Journey platform image to confirm Docker is working correctly:
docker run -d -p 3000:3000 --name devops-journey --restart=always devopsjourneyuz/devops-journey-uz:latestOpen http://server_ip:3000 in your browser, and you should see the DevOps Journey platform.
If the page does not load, check your firewall:
ufw (Ubuntu/Debian):
sudo ufw allow 3000
sudo ufw reloadfirewalld (RHEL/Fedora):
sudo firewall-cmd --zone=public --add-port=3000/tcp --permanent
sudo firewall-cmd --reloadSELinux (RHEL/Fedora) — if in enforcing mode:
sudo getenforce
# Temporarily disable (for testing):
sudo setenforce 0Configuring a proxy for Docker
Only perform this step if your server accesses the internet through a proxy.
If your organization's servers operate behind a proxy, you need to configure proxy settings for Docker as well:
sudo mkdir -p /etc/systemd/system/docker.service.d
sudo nano /etc/systemd/system/docker.service.d/http-proxy.confFile contents:
[Service]
Environment="HTTP_PROXY=http://myproxy:port"
Environment="HTTPS_PROXY=http://myproxy:port"
Environment="NO_PROXY=localhost,127.0.0.1"Apply the changes:
sudo systemctl daemon-reload
sudo systemctl restart dockerVerify:
docker info | grep -i proxyUpgrading Docker Engine
Via APT (Ubuntu/Debian)
If you installed Docker using the APT repository, upgrading is straightforward:
sudo apt update
sudo apt upgrade docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginVia DNF (Fedora/RHEL)
sudo dnf upgrade docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginVia the convenience script
Docker also provides a quick installation script. This is recommended only for testing and development environments:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.shDo not use this script in production! It does not allow customization of parameters and may result in unexpected major version upgrades.
To preview what the script will do:
sudo sh ./get-docker.sh --dry-runTo install pre-release (beta) versions:
curl -fsSL https://test.docker.com -o test-docker.sh
sudo sh test-docker.shUninstalling Docker Engine
- Ubuntu/Debian
- Fedora/RHEL
1-> Remove Docker packages:
sudo apt purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras2-> Remove images, containers, and volumes:
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd3-> Remove the repository source and GPG key:
sudo rm /etc/apt/sources.list.d/docker.sources
sudo rm /etc/apt/keyrings/docker.ascAdditional information
Sources used: docs.docker.com (opens in a new tab)
Date: 2023.11.19(November 19, 2023)
Last updated: 2026.02.12(February 12, 2026)
Author: Otabek Ismoilov
| Telegram (opens in a new tab) | GitHub (opens in a new tab) | LinkedIn (opens in a new tab) |
|---|