Docker Compose is a tool for defining and running multi-container Docker applications using a single YAML configuration file. With one command you can start all services, networks, and volumes for your entire application stack. This guide installs Docker Compose on Ubuntu 26.04 LTS.
Tested and valid on:
- Ubuntu 26.04 LTS
Prerequisites
- Ubuntu 26.04 LTS with Docker Engine installed
- A user with sudo privileges
Step 1 – Install Docker Compose Plugin
The Docker Compose v2 plugin is included with the Docker installation:
sudo apt install docker-compose-plugin -y
docker compose version
Step 2 – Install Standalone Docker Compose (optional)
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)"
-o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
Step 3 – Create a Sample docker-compose.yml
mkdir ~/myapp && cd ~/myapp
cat > docker-compose.yml << 'EOF'
services:
web:
image: nginx:alpine
ports:
- "8080:80"
volumes:
- ./html:/usr/share/nginx/html
db:
image: mysql:9
environment:
MYSQL_ROOT_PASSWORD: rootpass
MYSQL_DATABASE: appdb
EOF
mkdir html && echo 'Hello Docker Compose!
' > html/index.html
Step 4 – Start the Application
docker compose up -d
docker compose ps
Step 5 – View Logs
docker compose logs -f web
Step 6 – Stop and Remove
docker compose down
docker compose down -v # also removes volumes
Step 7 – Common Commands
docker compose up -d # start all services detached
docker compose stop # stop without removing
docker compose restart web # restart specific service
docker compose exec db bash # open shell in container
docker compose pull # pull updated images
Conclusion
Docker Compose is installed and working on Ubuntu 26.04 LTS. Define complex multi-container applications in a single docker-compose.yml and manage them with simple compose commands.