Docker Compose Installation on Debian 12 Bookworm

In this guide, we want to show you Docker Compose Installation on Debian 12 Bookworm and Start using it. You can use Docker Compose to manage different Docker containers. It allows each service to easily be in a separately managed container.

Now you can follow this guide to start your Docker Compose installation and use it.

Docker Compose Installation on Debian 12 Bookworm

Before starting your Docker Compose installation, you need some requirements.


You must log in to your server as a non-root user with sudo privileges. To do this, you can follow this guide on Initial Server Setup with Debian 12 Bookworm.

Also, you must have Docker CE installed on your server. For this purpose, you can visit this guide on Install Docker CE on Debian 12 Bookworm.

Then, follow the steps below to complete this guide.

Step 1 – Download and Install Docker Compose on Debian 12

To install Docker Compose, you need to confirm the latest version of Docker Compose on the releases page.

Now run the following command to download the 2.19.1 release:

# mkdir -p ~/.docker/cli-plugins/
# curl -SL -o ~/.docker/cli-plugins/docker-compose

Then, you need to set the correct permissions with the following command:

sudo chmod +x ~/.docker/cli-plugins/docker-compose

To see if your installation was successful run the following command:

docker compose version

In your output you will see:

Docker Compose version v2.19.1

Now you have successfully installed Docker Compose on Debian 12.

Let’s see how to set up the YAML file, and the minimal configuration required to run a container using Docker Compose.

Step 2 – Create a Docker Compose YAML File on Debian 12

To set up a YAML file, we create a web server environment using the official Nginx image from DockerHub. This containerized environment will serve a single static HTML file.

First, create a new directory in your home folder, then move into it with the following command:

# mkdir ~/compose-demo
# cd ~/compose-demo

Then, create a folder to serve as the document root for your Nginx environment with the following command:

mkdir app

Here you need to create a new index.html file with your favorite text editor, here we use vi:

vi app/index.html

Paste the following content into your file:

<!doctype html>
<html lang="en">
    <meta charset="utf-8">
    <title>Docker Compose Demo</title>
    <link rel="stylesheet" href="">

    <h1>This is a Docker Compose Demo Page.</h1>
    <p>This content is being served by an Nginx container.</p>


When you are finished, save and close the file.

Now you can create the YAML file with the following command:

vi docker-compose.yml

Then, paste the following content into the file:

version: '3.8'
    image: nginx:alpine
      - "8000:80"
      - ./app:/usr/share/nginx/html

The docker-compose.yml file typically starts with the version definition. This will tell Docker Compose which configuration version we’re using.

Save and close the file, when you are done.

Let’s see how to use Docker Compose on Debian 12.

Step 3 – How To Run a Container with Docker Compose?

At this step, you can execute Docker Compose to bring your environment up.

The following command will download the necessary Docker images, create a container for the web service, and run the containerized environment in background mode:

docker compose up -d

In your output you will see:

[+] Running 9/9
 ✔ web 8 layers [⣿⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                          4.9s
   ✔ 4db1b89c0bd1 Pull complete                                            0.9s
   ✔ bd338968799f Pull complete                                            1.5s
   ✔ 6a107772494d Pull complete                                            1.5s
   ✔ 9f05b0cc5f6e Pull complete                                            1.5s
   ✔ 4c5efdb87c4a Pull complete                                            1.6s
   ✔ c8794a7158bf Pull complete                                            1.7s
   ✔ 8de2a93581dc Pull complete                                            1.7s
   ✔ 768e67c521a9 Pull complete                                            2.6s
[+] Running 2/2
 ✔ Network compose-demo_default  Created                                   0.1s
 ✔ Container compose-demo-web-1  Started                                   0.7s

Your container is now up and running.

To see that your container is active, run the following command:

docker compose ps

Your output should be similar to this:

NAME                 IMAGE               COMMAND                  SERVICE             CREATED             STATUS              PORTS
compose-demo-web-1   nginx:alpine        "/docker-entrypoint.…"   web                 22 seconds ago      Up 21 seconds>80/tcp, :::8000->80/tcp

Now you can access the Docker Compose demo page on Debian 12 by typing your server’s IP address in your web browser followed by “:8000”:


You will see a page like this:

Docker compose demo page

Here we want to show you how to manage Docker Compose commands on Debian 12.

Step 4 – Common Docker Compose Commands

To check the logs produced by your Nginx container, you can use the following command:

docker compose logs

If you want to pause the container without changing the current state of your containers, you can use the following command:

docker compose pause
compose-demo-web-1  | / /docker-entrypoint.d/ is not empty, will attempt to perform configuration
compose-demo-web-1  | / Looking for shell scripts in /docker-entrypoint.d/
compose-demo-web-1  | / Launching /docker-entrypoint.d/
compose-demo-web-1  | info: Getting the checksum of /etc/nginx/conf.d/default.conf
compose-demo-web-1  | info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf

You can unpause the container with the following command:

docker compose unpause

To stop a container, you can use the Docker Compose stop command on Debian 12:

docker compose stop

If you want to remove the containers, networks, and volumes associated with this containerized environment, you can use the following command:

docker compose down
[+] Running 2/2
 ✔ Container compose-demo-web-1  Removed                                   0.0s
 ✔ Network compose-demo_default  Removed                                   0.2s

This command will not remove the base image, you can bring it up again with the docker-compose-up command.

To remove the base image from your system, you can use the following command:

docker image rm nginx:alpine
Untagged: nginx:alpine
Untagged: nginx@sha256:2d194184b067db3598771b4cf326cfe6ad5051937ba1132b8b7d4b0184e0d0a6
Deleted: sha256:4937520ae206c8969734d9a659fc1e6594d9b22b9340bf0796defbea0c92dd02

That’s it, you are done. For more information, you can visit Docker Compose Docs.


At this point, you have learned Docker Compose Installation in the Latest version on Debian 12 Bookworm and created a YAML file with it. Also, you have learned to run a container with Docker Compose and manage Docker Compose commands.

Hope you enjoy it. You may like these articles too:

Clear Pip Cache Safely

Configure Firewall with UFW on Debian 12 Bookworm

Stress Test and Benchmark CPU Performance Debian

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!