Install Docker Engine for the first time on a new host machine through apt repository. This is a quick installation guide covering most of the use cases. For more details please visit the official Docker website.
- Warning – Firewall limitations:
- If you use ufw or firewalld to manage firewall settings, be aware that when you expose container ports using Docker, these ports bypass your firewall rules. For more information, refer to Docker and ufw.
- Docker is only compatible with
iptables-nftandiptables-legacy. Firewall rules created withnftare not supported on a system with Docker installed. Make sure that any firewall rulesets you use are created withiptablesorip6tables, and that you add them to theDOCKER-USERchain, see Packet filtering and firewalls.
Prerequisites
OS Requirements
- Ubuntu Resolute 26.04 (LTS)
- Ubuntu Questing 25.10
- Ubuntu Noble 24.04 (LTS)
- Ubuntu Jammy 22.04 (LTS)
Uninstall Old Versions
Before you can install Docker Engine, you need to uninstall any conflicting packages.
The unofficial packages to uninstall are:
docker.iodocker-composedocker-compose-v2docker-docdocker-buildxpodman-docker
Run the following command to uninstall all conflicting packages:
sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc docker-buildx podman-docker containerd runc | cut -f1)
Set up Docker’s 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 the repository to Apt:
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
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
Refresh local listing of software packages:
sudo apt update
Install Docker Packages
Install the latest version of Docker packages:
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Install specific version of Docker packages:
To install a specific version of Docker Engine, start by listing the available versions in the repository:
apt list --all-versions docker-ce
Output for available versions:
docker-ce/noble 5:29.7.2-1~ubuntu.24.04~noble <arch>
docker-ce/noble 5:29.7.1-1~ubuntu.24.04~noble <arch>
…
Selected the desired version and install [Please update the version number below]:
VERSION_STRING=5:29.7.2-1~ubuntu.24.04~noble
sudo apt install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin
Verify Installation
After installation, verify that Docker is running:
sudo systemctl status docker
If Docker is not running, start it manually:
sudo systemctl start docker
Verify that the installation was successful:
sudo docker run hello-world
Post-Installation Steps for Linux
Manage Docker as a non-root User
To manage Docker as a non-root user you can run the following commands.
Create the docker group:
sudo groupadd docker
Add your user to the docker group:
sudo usermod -aG docker $USER
You can run the following command to activate the changes to groups:
newgrp docker
Verify that you can run docker commands without sudo:
docker run hello-world
Configure Docker to start on boot with Systemd:
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
To stop this behavior, use disable instead:
sudo systemctl disable docker.service
sudo systemctl disable containerd.service
Resource
Docker’s guide: https://docs.docker.com/engine/install/ubuntu/
Uninstall Docker: https://docs.docker.com/engine/install/ubuntu/#uninstall-docker-engine