Learn step-by-step how to install Docker on Debian 12 and unlock the power of containerization. Get started with our comprehensive guide.
Docker has revolutionized software development and deployment, providing a lightweight and efficient containerization solution.
In this article, we’ll walk you through the step-by-step process of installing Docker on Debian 12 (Bookworm), empowering you to take advantage of its powerful features.
Whether you’re a beginner or an experienced user, our easy-to-follow instructions will ensure a smooth installation. So let’s dive in!
Installing Docker on Debian 12
There are several ways you can install Docker on your Debian 12 system. It is available in the official Debian repositories, where it can be easily installed with a single APT command. However, one disadvantage to this approach is that the version available is not always the most recent.
For this reason, I will show you how to install Docker on Debian 12 from the official Docker repository. This approach guarantees you always get the latest up-to-date version and will automatically receive all future software updates as they become available. So, let’s get started.
Step 1: Install Prerequisites
First, run the two commands below to update the package index and install the prerequisite necessary to add and use a new HTTPS repository.
sudo apt update
sudo apt install apt-transport-https ca-certificates curl gnupg
Step 2: Add Docker’s GPG Repo Key
Next, import the Docker GPG repository key to your Debian system. This security feature ensures that the software you’re installing is authentic.
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker.gpg
Notice that the command produces no output.
Step 3: Add the Docker Repo to Debian 12
After importing the GPG keys, we’ll add the official Docker repository to our Debian 12 system. This implies that the update package will be made available with the rest of your system’s regular updates if a new version is released.
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/debian bookworm stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
As with the previous command, its execution produces no output.
Next, refresh the package list.
sudo apt update
As you can see, our new Docker repository is now available and ready to be used.
Step 4: Install Docker on Debian 12 (Bookworm)
To install the latest up-to-date Docker release on Debian, run the below command.
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin
This installs the following Docker components:
- docker-ce: The Docker engine itself.
- docker-ce-cli: A command line tool that lets you talk to the Docker daemon.
- containerd.io: A container runtime that manages the container’s lifecycle.
- docker-buildx-plugin: A CLI plugin that extends the Docker build with many new features.
That’s all! Docker should now be installed; the service started and enabled to start automatically on boot.
In addition, you can check the Docker service status using the following:
sudo systemctl is-active docker
Step 5: Verify the Docker Installation
Now let’s check if everything with our new Docker installation works properly. For this purpose, we will run a simple application called “hello-world.”
sudo docker run hello-world
Congratulations! As we can see, everything works as expected!
Enabling Non-root Users to Run Docker Commands
So far, we have successfully installed Docker on your Debian 12 system.
However, only root and users with sudo privileges can execute Docker commands by default. In other words, if you attempt to run the docker
command without prefixing it with sudo
, you’ll get an error message like this:
docker ps
So, to run Docker commands as a non-root user, you must add your user to the “docker” group. To do that, type in the following:
sudo usermod -aG docker ${USER}
In the above command, ${USER}
is an environment variable that holds your username. To apply for the new group membership, reboot your Debian system.
You can then execute Docker commands without prefixing them with sudo
.
Conclusion
Throughout this article, we have explored the step-by-step process of installing Docker on Debian 12 (Bookworm).
It is worth noting that Docker is continuously evolving, with new features, improvements, and updates being introduced regularly. As such, it is recommended to stay up to date with the latest releases and security patches to ensure a smooth and secure Docker experience.
To learn more about Docker, check out the official Docker documentation. Additionally, we recommend our detailed guide to expand your skills with Docker and learn how to run and manage multi-container applications using Docker Compose. Happy dockering!
Thank you very much for the guide. It’s my first time using Debian (used ubuntu server before), and with this guide I can get docker running in no time.
Thank you for your great work !
Thank you, very usefull !
While reading the Docker documentation, I got the impresion that only desktop users could install docker)
Thanks again !
Hi sabamimi,
Glad to have been of help.
No, Docker is not limited to desktop or server users. It is system-wide.
Best,
Bobby
Thanks, Bobby. Excellent doc; got me up and running first time thru. Cheers!!
You’re welcome! 🙂
Best,
Bobby