Installing Docker on Debian
Install Docker Engine and Docker Compose cleanly from the official repository – the foundation for most self-hosting recipes.
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
- A hardened server with a sudo user
Step by step
Step 1: Set up the repository key
First, install the tools needed to verify the Docker repository:
sudo apt update
sudo apt install -y ca-certificates curlThen create the keyring directory and download Docker’s GPG key – apt uses it later to check that the packages really come from Docker:
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.ascStep 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:
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/nullStep 3: Install Docker
Refresh the package lists (now including the Docker repository) and install the Engine together with the Compose plugin:
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-pluginCheck that the service is running:
sudo systemctl status dockerYou should see active (running). A quick smoke test:
sudo docker run --rm hello-worldThe output Hello from Docker! confirms that the installation works.
Finally, check which versions actually got installed – that’s the information every bug report will ask you for:
docker --version
docker compose versionDocker version 29.7.2, build a7dcaa6
Docker Compose version v5.4.0The exact patch numbers keep moving; what matters is that the Engine is on 29.x and Compose on v5.x – that’s what the Compose recipes here build on.
Step 4: Use Docker without sudo
Add your user to the docker group so you don’t have to prefix every command with
sudo:
sudo usermod -aG docker $USERTip
Security note
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: Package 'docker-ce' has no installation candidate. The package source from
step 2 is missing or malformed – apt only knows the name from the Debian packages'
dependencies and finds no package behind it. 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 API at unix:///var/run/docker.sock.
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 docker: unknown command: docker compose. 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 dfshows the usage,docker system prunecleans 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: Aug 10, 2026
Send feedback: feedback@serverkueche.de
What's next?

AdGuard Home: network-wide ad and tracking blocker
Set up AdGuard Home with Docker: your own DNS server that blocks ads, trackers and malicious sites for all devices – …

Stalwart: the lightweight mail server in a single container
Set up Stalwart Mail Server with Docker: SMTP, IMAP, JMAP and spam filter in a single, lean container – the modern …

Your own mail server with Mailcow: setup from scratch
Set up Mailcow (dockerized) on your own server: Postfix, Dovecot, Rspamd and SOGo webmail under your domain – a complete …

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

Understanding Docker Compose: services, volumes, networks
compose.yaml explained: services, volumes, networks and variables – the Docker vocabulary every app recipe in the …
You might also like

Understanding Docker Networks: bridge, internal DNS & the proxy network
Why does every app recipe declare a proxy network? This guide explains Docker networks, internal DNS and container …

unattended-upgrades: automatic security updates for Debian
Debian installs security updates automatically: set up unattended-upgrades, control the reboot, and verify it really …

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 …