J. JieraltField Notes
Technical guide

Install Docker Engine and Compose on Linux (Ubuntu / Debian)

Install Docker Engine, the CLI, Buildx and the Compose plugin from Docker's official apt repository, then verify the setup.

Scope: this guide uses 64-bit Ubuntu 22.04 / 24.04 and Debian as examples. Other distributions need their matching Docker instructions; do not copy apt commands blindly. Confirm you have sudo access and check the OS and CPU architecture first.

1. Check the system

cat /etc/os-release
dpkg --print-architecture

2. Add Docker's official apt repository

Install certificate and download tools, then add Docker's signing key:

sudo apt update
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.asc

For Ubuntu, create the repository configuration:

sudo tee /etc/apt/sources.list.d/docker.sources >/dev/null <<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

For Debian, change the signing-key URL to https://download.docker.com/linux/debian/gpg and the repository URIs value to https://download.docker.com/linux/debian; the other repository fields stay the same. Then refresh the package index:

sudo apt update

3. Install Engine, CLI and Compose

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

Compose is normally used as a Docker CLI plugin: docker compose (with a space), rather than the older standalone docker-compose command.

4. Start and verify

sudo systemctl enable --now docker
sudo systemctl status docker --no-pager
sudo docker run hello-world
docker compose version

If hello-world prints a success message, Docker Engine was able to pull and run a test container.

5. Should you use Docker without sudo?

Using sudo docker ... is the simplest default. A user in the docker group can generally exercise root-level control of the host, so only grant this access to trusted accounts:

sudo usermod -aG docker "$USER"

Log out and back in for the group change to take effect. Do not expose the Docker socket to the public internet or run images from untrusted sources without reviewing them.

Troubleshooting

  • permission denied: try sudo docker ps; if you just joined the docker group, log in again.
  • docker compose is missing: confirm docker-compose-plugin is installed, then run docker compose version.
  • Package not found: check the OS codename and architecture, confirm the official Docker repository was added, and rerun sudo apt update.
  • A cloud VM port is unreachable: check both the host firewall and the provider's security group. Only publish ports that should be publicly accessible.

Official references

Docker's supported distributions and repository setup may change. Check the official page for your exact OS release before applying this to production.

Still not working after these steps?

Send me the error and your environment for a free first diagnosis. Hands-on help is quoted before any work starts.

Get a free checkor ask the forum
Want new fixes as they land?Subscribe via RSS →