Skip to content
Serverküche
Search

Loading search … (only available on the published site).

Containers Difficulty: Beginner

Installing Docker on Debian

Install Docker Engine and Docker Compose cleanly from the official repository – the foundation for most self-hosting recipes.

· 3 min read ·Duration: approx. 15 minutes
Table of contents

Docker is the foundation for almost every application tutorial in the Serverküche. We install it from the official Docker repository – not from the Debian package sources.

What are we building?

By the end, the current Docker Engine with the Compose plugin runs on your Debian 13, installed from the official Docker repository. That has two advantages over the Debian package docker.io: more current versions with timely security updates, and the official docker compose that all Compose recipes here build on.

Prerequisites

Step by step

Step 1: Set up the repository key

First, install the tools needed to verify the Docker repository:

Terminal
sudo apt update
sudo apt install -y ca-certificates curl

Then create the keyring directory and download Docker’s GPG key – apt uses it later to check that the packages really come from Docker:

Terminal
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc

Step 2: Add the Docker package source

Add the Docker repository to your package sources. The command detects the architecture and Debian version automatically, so you can copy it unchanged:

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

Step 3: Install Docker

Refresh the package lists (now including the Docker repository) and install the Engine together with the Compose plugin:

Terminal
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin

Check that the service is running:

Terminal
sudo systemctl status docker

You should see active (running). A quick smoke test:

Terminal
sudo docker run --rm hello-world

The output Hello from Docker! confirms that the installation works.

Step 4: Use Docker without sudo

Add your user to the docker group so you don’t have to prefix every command with sudo:

Terminal
sudo usermod -aG docker $USER

Tip

The group membership only takes effect after you log out and back in (end the SSH session and reconnect).

Security note

Members of the docker group effectively have root rights on the server – only add your own admin user, no shared or unprivileged accounts.

After that, docker ps works without sudo and shows a (still empty) container list.

When things go wrong

E: Unable to locate package docker-ce. The package source from step 2 is missing or malformed. Check the contents of /etc/apt/sources.list.d/docker.list – it must contain your Debian version (e.g. trixie) – and then run sudo apt update again.

permission denied while trying to connect to the Docker daemon socket. The docker group membership hasn’t taken effect yet. End the SSH session and reconnect; groups must then include docker. If not, repeat step 4.

Conflicts during installation with already-present packages. Another Docker variant is already installed (docker.io, podman-docker, …). Remove the old packages first: sudo apt remove docker.io docker-doc docker-compose podman-docker containerd runc – existing containers/images are preserved.

docker compose reports 'compose' is not a docker command. The Compose plugin is missing – Docker was probably installed differently earlier. Run sudo apt install docker-compose-plugin. Note: the old docker-compose (with a hyphen) is a different, outdated tool.

Maintenance & backups

  • Updates: Docker updates along with the normal sudo apt update && sudo apt upgrade – one reason we use the official repository. When the Engine is updated, running containers restart briefly (or stop until you start them again) – plan for that.
  • Cleanup: Unused images and build leftovers pile up quickly. docker system df shows the usage, docker system prune cleans up (careful: it also removes stopped containers).
  • Backups: The actual data of your applications will later live in volumes or bind mounts – we build the backup strategy for that with encrypted Restic backups and in the individual application tutorials.

Last updated: Jul 19, 2026

What's next?

Restic backups: encrypted and off-site
Security Intermediate

Restic backups: encrypted and off-site

Off-site backups with Restic: set up encrypted, restore snapshots, prune with retention and automate via a systemd …

· 11 min read

You might also like

Setting up a firewall with UFW
Security Beginner

Setting up a firewall with UFW

Set up a host firewall in minutes with UFW: block everything except SSH, HTTP and HTTPS on your server – without ever …

· 4 min read
First steps with a netcup VPS
Basics Beginner

First steps with a netcup VPS

From a freshly ordered netcup server to a ready-to-use system: SSH login, system updates, a sudo user and the most …

· 4 min read