How to Install Docker Compose on Ubuntu & Debian

Docker Compose lets you define and run multi-container applications from a single YAML file, instead of running multiple long docker run commands manually. Modern Docker installations include Compose as an integrated docker compose plugin rather than a separate binary.

Prerequisites

  • Docker Engine already installed
  • Root or sudo access

Step 1 — Check If Compose Is Already Installed

docker compose version

If this returns a version number, you're already set — it ships with Docker Engine installed via the official repository.

Step 2 — Install the Compose Plugin (If Missing)

sudo apt update
sudo apt install docker-compose-plugin -y

Step 3 — Verify

docker compose version

Step 4 — Create a Test Project

mkdir ~/compose-test && cd ~/compose-test
nano docker-compose.yml
services:
  web:
    image: nginx:latest
    ports:
      - "80:80"
    restart: unless-stopped

Step 5 — Start the Stack

docker compose up -d

Step 6 — Verify It's Running

docker compose ps
docker ps

Visit http://YOUR_SERVER_IP in a browser — you should see the default Nginx page.

Step 7 — Stop the Stack

docker compose down

Essential Compose Commands

CommandPurpose
docker compose up -dStart services in the background
docker compose downStop and remove containers
docker compose restartRestart all services
docker compose logs -fFollow logs from all services
docker compose psList running services in this project
docker compose pullDownload the latest images
docker compose configValidate the YAML syntax

Note on the Legacy docker-compose Binary

You may still see the standalone docker-compose (with a hyphen) command referenced in older tutorials. It's deprecated in favor of the integrated docker compose (no hyphen) plugin used throughout current Docker documentation and this guide.

Common Errors

"docker: 'compose' is not a docker command" — the plugin isn't installed; run Step 2 above.

YAML syntax errors — validate before starting:

docker compose config

Remember YAML requires spaces, never tabs, for indentation.

Best Practices

  • Keep one docker-compose.yml per project/application
  • Use restart: unless-stopped for production services
  • Store secrets in a .env file rather than hardcoding them in the YAML

FAQ

What's the difference between docker-compose and docker compose?
They're functionally similar, but docker compose (the plugin, no hyphen) is the current, actively maintained version and is installed alongside Docker Engine by default via the official repository.

Related Articles

  • How to Install Docker Engine on Ubuntu & Debian
  • Docker Compose .env and Environment Variables
  • Docker Compose Troubleshooting: Common Errors & Fixes
  • docker compose, docker compose v2, install docker compose, ubuntu, debian
  • 0 Користувачі, які знайшли це корисним
Ця відповідь Вам допомогла?

Схожі статті

How to Install Docker Engine on Ubuntu & Debian (Complete Guide)

Docker lets you package applications and their dependencies into lightweight, isolated containers...

Deploy Your First Docker Container: A Beginner's Walkthrough

With Docker installed, this hands-on walkthrough covers the core workflow you'll use constantly:...

How to Update Docker and Docker Compose Safely

Keeping Docker Engine and Compose updated brings security fixes, performance improvements, and...

Docker Compose Troubleshooting: Common Errors & Fixes

A reference guide to the Docker and Docker Compose errors you're most likely to encounter, with...

How to Install Portainer for Web-Based Docker Management

Portainer provides a graphical web dashboard for managing Docker containers, images, networks,...