Docker Compose Reference
Full API documentation for Docker Compose commands, configuration, and usage.
Core Commands
docker-compose up
Build, (re)create, start, and attach to containers for a service.
docker-compose up [-d] [SERVICE...]
⭐ Flag:
-d
runs in detached mode
docker-compose build
Build or rebuild service images.
docker-compose build [SERVICE...]
⚙️ Supports multi-stage builds
docker-compose logs
View output from containers.
docker-compose logs [SERVICE...]
🔄 Real-time tail with
--follow
docker-compose down
Stop and remove containers, networks, etc.
docker-compose down [-v]
🗑
-v
removes named volumes too
Compose File Configuration
Services
-
▸
image
Container image to use
-
▸
ports
Port mappings
-
▸
volumes
Mount storage locations
-
▸
depends_on
Dependency order
-
▸
environment
Env variables
Networks
-
▸
driver
Network driver (default: bridge)
-
▸
external
Use existing network
-
▸
name
Custom network name
Volumes
-
▸
type
Mount type (bind, volume, tmpfs)
-
▸
source
Path on the host
-
▸
target
Path in container
-
▸
read_only
Make read-only
Example: Multi-Service Setup
version: '3.8'
services:
web:
build: .
ports:
- "8000:5000"
volumes:
- data:/var/www
environment:
- DEBUG=1
networks:
default:
driver: bridge
volumes:
data:
Complete CLI Reference
Command | Description |
---|---|
docker-compose up | Start services |
docker-compose ps | List running containers |
docker-compose pause | Pause services |
docker-compose images | List images |
Need help?
Join our community forums or view the full reference guide.