How to Install Docker and Docker Compose on Debian 12 'Bookworm'

Learn how to install Docker and Docker Compose on Debian 12 "Bookworm" with our step-by-step guide.

Publish date: 5/30/2024

Docker is a game-changer when it comes to deploying applications in a modern way. It massively simplifies the deployment process.

And whether you're a newbie or a seasoned pro, this guide will walk you through the process of installing Docker and Docker Compose on Debian 12 Bookworm, one of the most reliable Linux operating systems available today.

Let's dive in.

Installing Docker

Step 1) Update your system

Before starting, ensure your system is up-to-date.

You can do that with the following commands:

sudo apt update 
sudo apt upgrade

Step 2) Install necessary packages

Next install the necessary packages for setting up the Docker repository:

sudo apt install ca-certificates curl gnupg dpkg lsb-release

Step 3) Add Docker’s official GPG key

You can use the following commands to add Docker's official GPG key to your system:

sudo install -m 0755 -d /etc/apt/keyrings 

sudo curl -sS | sudo gpg --dearmor > /usr/share/keyrings/docker-ce.gpg

sudo chmod a+r /usr/share/keyrings/docker-ce.gpg

Step 4) Set up the Docker repository

Add the Docker repository to your APT sources:

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-ce.gpg] $(lsb_release -sc) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Step 5) Update the package index

Next update the package index to include the Docker repository:

sudo apt update

Step 6) Install Docker Engine, Docker CLI, and Docker Compose

Finally, install Docker Engine, Docker CLI, and the Docker Compose plugin:

sudo apt install docker-ce docker-ce-cli docker-buildx-plugin docker-compose-plugin

Step 7) Verify Docker installation

To verify that Docker is installed correctly, run the following command:

sudo docker run hello-world

This command downloads a test image and runs it in a container.

If everything is set up correctly, you will see a message indicating that Docker is working.

Step 8) Verify your Docker Compose installation

To test that Docker Compose is working properly, you can create a docker-compose.yml file with the following content inside to set up a simple Nginx web server:

    image: nginx:alpine
      - "80:80"

You can create the file with nano docker-compose.yml and to run it, use the following command (after saving):

docker compose up -d

This will start an Nginx web server in a detached Docker container.

You can verify that it's working by opening a web browser and navigating to http://localhost. You should see the default Nginx welcome page.

To stop and remove the containers, run:

docker compose down

Step 9) Manage Docker as a non-root user

By default, only the root user and users with sudo privileges can run Docker commands.

To allow a non-root user to run Docker commands, add the user to the docker group:

sudo usermod -aG docker $USER && newgrp docker

Log out and log back in for the changes to take effect.


Congratulations! You've successfully installed Docker and Docker Compose on Debian 12 Bookworm.

Whether you're hosting applications, testing software, or developing new solutions, Docker provides a great platform to do so.

For more tips and detailed guides, in regards to Docker specifically check out the official Docker documentation.

And if you need reliable hosting; for large scale production services, should be your first stop. For smaller and more scale oriented projects, or personal projects, our NVMe V.PS line is an excellent option.

Happy Dockering and thanks for reading!