back to docs
server-setup

Docker

Install the latest stable Docker Engine on your server

1. Prerequisites

Supported Ubuntu versions (64-bit only):

  • Ubuntu Noble 24.04 (LTS)
  • Ubuntu Jammy 22.04 (LTS)
  • Ubuntu Plucky 25.04
  • Ubuntu Questing 25.10

Firewall Notice: When you expose container ports using Docker, these ports bypass firewall rules managed by ufw or firewalld.

2. Remove conflicting packages

Before installing Docker, remove any conflicting packages:

sudo apt remove docker.io docker-compose docker-compose-v2 docker-doc podman-docker containerd runc

3. Set up Docker’s APT repository

a. Install prerequisites

sudo apt update -qy
sudo apt install ca-certificates curl

b. Add Docker’s official GPG key

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

c. Add the repository to APT sources

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

d. Update the package index

sudo apt update -qy

4. Install Docker Engine

a. Install the latest version

sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

b. Install a specific version (optional)

To install a specific version, first list available versions:

apt-cache madison docker-ce | awk '{ print $3 }'

Then install with version string:

VERSION_STRING=5:27.1.1-1~ubuntu.22.04~jammy
sudo apt install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin

c. Quick install (alternative)

If you prefer a quick setup using Docker’s convenience script:

curl -fsSL https://get.docker.com | sh
sudo systemctl start docker && sudo systemctl enable docker
sudo usermod -aG docker $USER
Note
This method is fine for development or testing. For production, use the APT repository method above.

5. Verify the installation

Test that Docker is installed correctly:

sudo docker run hello-world

Check Docker service status:

sudo systemctl status docker
Note
The Docker service starts automatically on Debian-based distributions after installation.

6. Post-Installation

To run Docker commands without sudo, add your user to the docker group:

sudo usermod -aG docker $USER
newgrp docker

Verify it works:

docker run hello-world

7. Uninstall Docker (if needed)

To completely remove Docker:

sudo apt purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
sudo rm -rf /var/lib/docker /var/lib/containerd
Command Palette
Search for a command to run...