How to Install Docker Compose on Ubuntu 24.04
Docker Compose is a tool that helps developers manage as well as run applications made up of multiple Docker containers. It simplifies the steps needed to start and connect the containers as a single application. With Docker Compose, you can define and run complex applications using a YAML file, making it easier to manage the many moving parts of modern software systems.
Installing Docker Compose on Ubuntu 24.04 is straightforward and enhances your Docker experience by enabling you to manage multi-container applications efficiently. It allows users to define and start all the services from a single file.
This article will explain the step-by-step instructions for installing Docker Compose on an Ubuntu 24.04 system.
Let’s begin the installation of Docker Compose.
How to Install Docker Compose on Ubuntu 24.04?
First, ensure that Docker Engine and Docker CLI are pre-installed on the Ubuntu system. If users are required to install Docker, they can find the guide on Docker’s documentation. After installation, check its version:
docker --version
For the installation of Docker Compose on an Ubuntu 24.04 system, follow the below methods:
Let’s start with the easiest one.
Method 1: Install Docker Compose on Ubuntu 24.04 Using the Ubuntu Default Repository
If you’re using Ubuntu 24.04 and looking to install Docker Compose from the default repositories, follow the below step-by-step procedure:
Step 1: Update Package List
Begin by updating the package list to make sure that users have access to the latest packages as well as software versions:
sudo apt update
Step 2: Install Docker Compose
With the package database updated, users can now install Docker Compose with the help of “docker-compose” package name:
sudo apt install docker-compose
Note: If the user finds any issue, execute the “sudo apt install docker-compose-plugin” command for installation.
Step 3: Verify Installation
After the installation is done, users can authenticate whether Docker Compose is correctly installed or not by checking its version:
docker compose version
You’ve now successfully installed Docker Compose on your Ubuntu 24.04 system.
For massive information and advanced usage, users can navigate to the Docker documentation.
Method 2: Install Docker Compose on Ubuntu 24.04 Using Docker Repository
To install Docker Compose on Ubuntu 24.04 using the Docker repository, you will need to follow these steps:
Step 1: Install Docker Engine
Docker Compose requires the Docker engine to function. If users haven’t pre-installed Docker, they can achieve this by updating your package index and installing the Docker package with the “apt” commands:
sudo apt update sudo apt install docker.io
After successful installation, users can start and enable the Docker service to ensure it’s running:
sudo systemctl start docker sudo systemctl enable docker
Step 2: Download Docker Compose
With Docker installed, users can now download the latest release of Docker Compose from the GitHub repository. For instance, the stable release is version 2.26.1. They can download it using “wget” utility:
wget https://github.com/docker/compose/archive/refs/tags/v2.26.1.tar.gz
Then, extract the downloaded file with the “tar” command with the “xzf” option:
tar -xzf v2.26.1.tar.gz
Step 3: Install Docker Compose
Now, navigate to the extracted folder and install Docker Compose with the “make” command:
cd compose-2.26.1 make install
If the user finds any issue, install docker-engine or dependencies via the “sudo apt install docker-buildx-plugin” command.
Step 4: Create a Symbolic Link
After downloading, it is a good approach for creating a symbolic link to avoid any conflict. It is based on user needs:
sudo ln -s ~/compose-2.26.1/bin/build/docker-compose /usr/local/bin/docker-compose
Step 5: Verify Installation
To ensure Docker Compose is installed correctly, execute the “docker-compose” in the terminal:
docker-compose
This command output confirms the successful installation of Docker Compose.
Note: It’s important to note that Compose V1 is no longer updated in July 2023, and Compose V2 has taken its place and is integrating it into all current Docker versions.
How to Use/Configure Docker Compose on Ubuntu 24.04?
Now Docker Compose is installed, users can configure Docker Compose by creating and editing the .yml file as below:
Step 1: Create and Edit a “docker-compose.yml” File
First, create a “docker-compose.yml” file in the project folder. After that, define its services. For instance, create a .yml file via the “touch” command and edit it via the nano editor:
touch docker-compose.yml nano docker-compose.yml
After creating the file, set the rules for docker-compose by adding the below lines in .yml configuration file:
version: '3' services: web: image: nginx ports: - "80:80" database: image: postgres environment: POSTGRES_PASSWORD: mysecretpassword
Then, save and close the file.
Validate the .yml File
Now, validate the configuration file after setting rules for docker-compose:
docker-compose config
Step 2: Start Docker Compose Services
Now, run “docker-compose up” for starting services as defined in the YAML file. Here, the “d” option is utilized to run services in the background:
docker-compose up -d
Step 3: Check Containers Status
Now, users can check/verify the containers’ status with the “docker-compose” command with the “ps” option:
docker-compose ps
Step 4: Pull Down Containers
Users can pull down the containers using the “docker-compose” command with the “down” option:
docker-compose down
To explore more commands, follow our detailed guide on Ubuntu.
Conclusion
To install Docker Compose on Ubuntu 24.04 using the Docker repository, ensure Docker Engine and Docker CLI are installed on the system. Then, set up Docker’s repository and install the Docker Compose with the “sudo apt install docker-compose” command.
To configure/use the Docker Compose on Ubuntu, ensure Docker Compose is installed. Then, create a “docker-compose.yml” file in the project folder and define the application’s services. Finally, users can utilize it to run applications.











