Skip to content
Documentation
Installing Docker on Linux

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

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 update

What do these commands do?

  • GPG key — verifies that downloaded packages genuinely come from Docker
  • APT source — provides the apt package 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 -y

Where:

  • docker-ce — Docker Engine (the core engine)
  • docker-ce-cli — Docker CLI (command-line interface)
  • containerd.io — container runtime
  • docker-buildx-plugin — extended build capabilities
  • docker-compose-plugin — the docker compose command (for multi-container applications)

3-> Start Docker and verify it is running:

sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker

4-> Verify that the installation was successful:

sudo docker run hello-world

This 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 $USER

For 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 docker

Then verify that it works without sudo:

docker run hello-world

Verifying 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:latest

Open 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 reload

firewalld (RHEL/Fedora):

sudo firewall-cmd --zone=public --add-port=3000/tcp --permanent
sudo firewall-cmd --reload

SELinux (RHEL/Fedora) — if in enforcing mode:

sudo getenforce
# Temporarily disable (for testing):
sudo setenforce 0

Configuring 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.conf

File contents:

http-proxy.conf
[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 docker

Verify:

docker info | grep -i proxy

Upgrading 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-plugin

Via DNF (Fedora/RHEL)

sudo dnf upgrade docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Via 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.sh

Do 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-run

To install pre-release (beta) versions:

curl -fsSL https://test.docker.com -o test-docker.sh
sudo sh test-docker.sh

Uninstalling Docker Engine

1-> Remove Docker packages:

sudo apt purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras

2-> Remove images, containers, and volumes:

sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd

3-> Remove the repository source and GPG key:

sudo rm /etc/apt/sources.list.d/docker.sources
sudo rm /etc/apt/keyrings/docker.asc

Additional 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)