Debian 12 is an excellent Docker host: it is stable, minimal, and stays out of the way of your workloads. But to install Docker on Debian 12 the right way, you should use Docker’s official repository rather than the distribution’s older docker.io package — you get current Engine releases, the Compose v2 plugin, and BuildKit, all updated through APT like everything else on the system.
This tutorial walks through installing Docker Engine on Debian 12 (Bookworm) from the official Docker repository, verifying the installation, running containers safely as a non-root user, and enabling the services at boot. It also explains the differences from Debian’s packaged version so you can choose deliberately.
Prerequisites to Install Docker on Debian 12
- A 64-bit Debian 12 system (amd64, arm64, or armhf) with at least 2 GB of RAM.
- A user with sudo privileges and internet access.
- Any previous Docker installation removed, to avoid conflicts between packages.

Step 1: Remove Conflicting Packages
Debian ships its own Docker build as docker.io, plus related packages such as podman-docker that conflict with the official one. Remove anything present:
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do
sudo apt remove -y $pkg
done
Removing the packages does not delete your existing images and containers in /var/lib/docker; they will still be there if you reinstall later.
Step 2: Add Docker’s Official Repository
Install the prerequisites, then store Docker’s signing key in /etc/apt/keyrings — the modern, per-repository key pattern we recommend in our guide to the Debian sources.list:
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/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
Now add the repository itself, using the version codename from your system:
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
sudo apt update
Confirm with apt-cache policy docker-ce that the candidate version comes from download.docker.com.
Step 3: Install Docker on Debian 12
Install the Engine, CLI, containerd runtime, and the Buildx and Compose plugins:
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
The Docker service starts automatically. Verify it:
sudo systemctl status docker
sudo docker run hello-world
The hello-world container downloads a tiny test image and prints a confirmation message, proving that pulling images, creating containers, and networking all work.
Step 4: Run Docker as a Non-Root User
By default only root (or sudo) can talk to the Docker daemon. Adding your user to the docker group removes that friction:
sudo usermod -aG docker $USER
Log out and back in, then test with docker run hello-world without sudo. Understand the trade-off: membership in the docker group is effectively root-equivalent, because a user who can start containers can mount the host filesystem into one. Only grant it to trusted administrators — the same caution applies as with sudo itself.
Step 5: Useful First Configuration
Enable both services so containers survive reboots, and set containers to restart automatically where appropriate with the --restart unless-stopped flag or Compose’s restart: key. To stop images from filling the disk, configure log rotation in /etc/docker/daemon.json:
{
"log-driver": "json-file",
"log-opts": { "max-size": "10m", "max-file": "3" }
}
Restart the daemon afterwards with sudo systemctl restart docker. A Docker host also benefits from a lean firewall: Docker programs nftables/iptables rules itself for published ports, so read the official Docker packet filtering documentation before hand-editing host firewall rules, since the interaction surprises many administrators.
Step 6: Test Docker Compose
Compose v2 is a plugin, invoked as docker compose (with a space). Check it:
docker compose version
A minimal Compose file for a test web service looks like this:
services:
web:
image: nginx:alpine
ports:
- "8080:80"
restart: unless-stopped
Start it with docker compose up -d and browse to port 8080. Stop it with docker compose down. If you are migrating from an Ubuntu host, our guide on how to install Docker on Ubuntu 24.04 shows the parallel steps for that platform.
Troubleshooting
“permission denied” from the Docker socket
Your group membership has not taken effect in the current shell. Log out completely (or reboot) rather than opening a new tab, then retry.
apt cannot find docker-ce after adding the repo
Run sudo apt update and watch for errors on the docker.list entry — usually a missing key file or a wrong codename. On Debian the codename must be bookworm; using an Ubuntu codename here is a frequent copy-paste mistake.
Containers lose network access after firewall changes
Restart the docker service after changing host firewall rules so it can rebuild its chains, and avoid flushing the ruleset Docker manages.
Conclusion
You now install Docker on Debian 12 the maintainable way: official repository, signed packages, Compose v2 included, log rotation configured, and unprivileged access granted deliberately rather than by habit. Debian’s stability plus Docker’s packaging gives you a container host that updates cleanly for years. Next steps for a serious deployment are automatic security updates for the host, regular image pruning (docker system prune), and backups of your volumes alongside the rest of the server.