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.
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: 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 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: Jul 19, 2026
Send feedback: feedback@serverkueche.de
What's next?

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

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 …

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 …