How to Install Docker Compose on Ubuntu 24.04

2026-09-11 38 Docker Guides
How to Install Docker Compose on Ubuntu 24.04

Docker Compose is a tool for running and managing multiple Docker containers using a single YAML configuration file. Instead of starting each container manually, you can define your application, ports, networks, volumes, and environment variables in a compose.yaml file.

In this guide, we will install Docker Compose on Ubuntu 24.04 LTS, verify the installation, and launch our first Docker Compose project.

Requirements

Before you begin, make sure you have:

  • a server running Ubuntu 24.04 LTS;

  • Docker Engine installed;

  • SSH access to the server;

  • a user with sudo or root privileges.

If Docker is not installed yet, follow our guide “How to Install Docker on Ubuntu 24.04” first.

Check Docker Installation

Before installing Docker Compose, make sure Docker is installed and working:

docker --version

You can also check the Docker service status:

sudo systemctl status docker

If Docker is running correctly, you should see:

active (running)

Press q to exit the status screen.

Install Docker Compose

Modern versions of Docker Compose are distributed as an official Docker CLI plugin.

First, update the package index:

sudo apt update

Install the Docker Compose plugin:

sudo apt install docker-compose-plugin -y

After the installation is complete, check the installed version:

docker compose version

The command should display the currently installed version of Docker Compose.

docker compose vs docker-compose

Older tutorials often use the following command:

docker-compose

This refers to the older standalone implementation of Docker Compose.

Modern Docker installations use:

docker compose

Therefore, for new servers and projects, it is recommended to use the docker compose command.

Create Your First Docker Compose Project

Create a directory for the project:

mkdir ~/docker-test
cd ~/docker-test

Create a Compose configuration file:

nano compose.yaml

Add the following configuration:

services:
  nginx:
    image: nginx:latest
    container_name: nginx-test
    restart: unless-stopped
    ports:
      - "80:80"

Save the file.

If you are using Nano, press:

Ctrl + O
Enter
Ctrl + X

Start the Docker Compose Project

Start the project:

docker compose up -d

The -d option runs the containers in detached mode, allowing them to continue running in the background.

Docker will automatically download the Nginx image and create the container.

Check the project status:

docker compose ps

You can also check all running Docker containers:

docker ps

If port 80 is accessible from the Internet, open the following address in your browser:

http://SERVER_IP_ADDRESS

You should see the default Nginx welcome page.

View Docker Compose Logs

To view the logs of your project, run:

docker compose logs

To follow the logs in real time:

docker compose logs -f

Press:

Ctrl + C

to stop following the logs.

This does not stop the containers.

Restart Containers

To restart all services in the project:

docker compose restart

To stop the services:

docker compose stop

To start them again:

docker compose start

Stop and Remove a Docker Compose Project

To stop and remove the containers created by Docker Compose:

docker compose down

Docker images are normally kept on the server.

If you also want to remove the project's volumes:

docker compose down -v

Use this command carefully. Docker volumes may contain databases, application files, and other important persistent data.

Update Docker Compose Containers

To download newer versions of the images used by your project:

docker compose pull

Then recreate the containers:

docker compose up -d

Docker Compose will recreate the containers using the downloaded images when necessary.

Useful Docker Compose Commands

Start the project:

docker compose up -d

List project containers:

docker compose ps

View logs:

docker compose logs -f

Restart containers:

docker compose restart

Stop containers:

docker compose stop

Stop and remove the project containers:

docker compose down

Download newer images:

docker compose pull

Validate and display the Compose configuration:

docker compose config

Conclusion

Docker Compose makes it much easier to deploy and manage applications consisting of one or multiple containers. The project configuration is stored in a compose.yaml file, making it easy to reproduce the same environment on another VPS or dedicated server.

With Docker and Docker Compose installed, you can deploy web servers, databases, monitoring systems, control panels, and many other applications using only a few commands.

For further Docker administration, see our “Essential Docker Commands: A Beginner's Cheat Sheet” guide.