I recently needed to setup a Debian 12 server with Docker and was surprised to find out the Debian 12 doesn’t come with the “official” repository of Docker, whilst looking up the process of getting Docker running properly, I noticed a lot of posts where others had issues getting Docker running, so I thought this would be the best first official blog post for my site.
Before we begin!
First of for context I’m writing this guide with a fresh install of Debian 12.11.0, that’s running on a VM, hosted on a Proxmox server. It might not be important but context is context.
Let’s Go!
Regardless of where you read, the first step for any Linux server related install of software should always be to make sure everything is up to date, so let’s get that sorted right now!
Debian (minimal) doesn’t come with sudo by default and although you can install it, you don’t need to, with that in mind we will focus on the task at hand.
Access Root
To access root you simply type:
noob@debian:~$ su -
Password: [Type your password]
root@debian:~# < now you are root!
Note!
You will need to stay in root for the rest of this tutorial, after which you can type
exitto leave root and return to your normal user, please remember to be careful running commands in root.
Time to update
Like I said before, regardless of what you’re installing ALWAYS update first!
noob@debian:~$ apt update && apt upgrade -y
Understanding the update code
The first part apt update checks external repositories and updates your system’s knowledge of available packages and versions,
the apt upgrade section tells your server to start updating the packages that has a newer version available, the -y part confirms the install to all packages,
it’s not required but after you’ve been doing it for a while, especially on a new server you will want it, finally the && section just connects the two commands together, it’s also not required but I like it.
Setting up Docker
To install Docker on Debian 12 you first need to remove the “unofficial” Docker repository that comes with Debian, if you don’t remove it there have been reports of issues causing days of problem solving.
Remove the unofficial Docker repository
removing the unofficial container is actually very simple, first run:
noob@debian:~$ for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do apt-get remove $pkg; done
[Optional] If you tried installing containers before and want to start with a clean install then run:
noob@debian:~$ apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
Add the Docker repository
The simplest way (according to Dockers Documentation) is to run the mini-script below, this script can be copy and pasted directly into your terminal:
# Add Docker's official GPG key:
apt-get update
apt-get install ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
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" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
Install Docker
Now that you have the correct repository on your server its time to get Docker installed.
noob@debian:~$ apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
This might take a hot minute so just be patient it’s doing what it needs to do.
Test Docker works
That’s right, it’s time! are you excited? ok, calm down its just a docker install.
To test if docker is running properly, first type clear into your terminal and hit enter, this simply clears the terminal making it easier to read and understand any output that the next command produces.
noob@debian:~$ docker run hello-world
If you did everything correctly you see the output below from the command above, that’s it! Nicely done.
root@debian:~# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
e6590344b1a5: Pull complete
Digest: sha256:ec153840d1e635ac434fab5e377081f17e0e15afab27beb3f726c3265039cfff
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/