Install Docker Engine on Ubuntu/Debian: Step-by-Step Guide
This guide walks you through installing Docker Engine and Docker Compose on Ubuntu/Debian systems using Docker's official repository. Follow the steps in order.
1. Remove conflicting packages
First, remove any older or conflicting Docker-related packages:
sudo apt remove docker.io docker-compose docker-compose-v2 docker-doc docker-buildx podman-docker containerd runcIt's okay if some of these packages aren't installed — the command will just skip them.
2. Add Docker's official repository
Update your package list:
sudo apt updateInstall the required dependencies and add Docker's GPG key:
sudo apt install -y 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.ascThen add the repository to your 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 "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullUpdate again so APT picks up the new repository:
sudo apt update3. Install Docker + Compose
Install the official Docker Engine packages, including Buildx and modern docker compose:
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin4. Allow your user to run Docker without sudo
Add your user to the docker group:
sudo usermod -aG docker $USERThen either log out and log back in, or run:
newgrp dockerDocker documents this as the standard post-install setup for running Docker commands as a non-root user.
5. Test
Verify the installation:
docker --version
docker compose version
docker run hello-worldYou should now be able to use commands like:
docker ps
docker images
docker compose up -d
docker compose down6. Check the Docker service
Confirm the Docker service is running:
sudo systemctl status dockerOn Debian/Ubuntu-based systems, Docker normally starts automatically after installation.
Tagged
Written by
Abhishek Ghimire
Writes here about engineering, technology, and the things worth building.