Skip to main content
Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file.
1

Update package lists

First, update your package lists:
sudo apt update
2

Install Docker Compose

Install Docker Compose using the apt package manager:
sudo apt install docker-compose -y
This installs Docker Compose from Ubuntu’s official repositories.
3

Verify version

Check that Docker Compose was installed successfully:
docker-compose --version
You should see output similar to Docker Compose version v2.20.0.
4

Done

You can now run multi-container applications using Docker Compose.

Alternative: Install latest version

For the latest version, you can install Docker Compose directly:
# Download the latest version
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

# Make it executable
sudo chmod +x /usr/local/bin/docker-compose

# Verify installation
docker-compose --version

Basic Docker Compose usage

Create a docker-compose.yml file

version: '3.8'
services:
  web:
    image: nginx:alpine
    ports:
      - "80:80"
  db:
    image: postgres:13
    environment:
      POSTGRES_DB: myapp
      POSTGRES_USER: user
      POSTGRES_PASSWORD: password

Start services

docker-compose up -d

Stop services

docker-compose down

View logs

docker-compose logs

Next Steps

Now that Docker Compose is installed, you can:
  • Define multi-container applications
  • Manage complex deployments
  • Use environment variables and volumes
  • Scale services easily

Build docs developers (and LLMs) love