Docker Compose — Up and Down
The two most important Compose commands are docker compose up and docker compose down. This page covers all the options and behavior of these essential commands.
docker compose up
up creates and starts containers, networks, and volumes defined in your compose file.
Basic Usage
# Start in foreground (logs stream to terminal)
docker compose up
# Start in background (detached)
docker compose up -d
Common Options
# Start in background
docker compose up -d
# Rebuild images before starting
docker compose up --build
# Force recreate containers (even if config unchanged)
docker compose up --force-recreate
# Start specific services only
docker compose up -d web db
# Remove orphan containers (services removed from compose file)
docker compose up --remove-orphans
# Scale a service
docker compose up -d --scale web=3
# Wait for services to be healthy
docker compose up --wait
What up Does
docker compose up:
1. Reads compose.yml
2. Creates networks (if not exist)
3. Creates volumes (if not exist)
4. Pulls images (if not local)
5. Builds images (if build: specified)
6. Creates containers
7. Starts containers (respecting depends_on order)
8. Attaches to logs (foreground) or detaches (with -d)
docker compose down
down stops containers and removes containers, networks, and optionally volumes and images.
Basic Usage
# Stop and remove containers + networks
docker compose down
Expected output:
[+] Running 3/3
✔ Container myapp-web-1 Removed
✔ Container myapp-db-1 Removed
✔ Network myapp_default Removed
Common Options
# Remove containers + networks (default)
docker compose down
# Also remove named volumes
docker compose down -v
# Also remove images
docker compose down --rmi all
# Remove only locally-built images
docker compose down --rmi local
# Remove orphan containers
docker compose down --remove-orphans
# Timeout for graceful shutdown (default 10s)
docker compose down -t 30
What down Removes
| Flag | Containers | Networks | Volumes | Images |
|---|---|---|---|---|
down |
✅ | ✅ | ❌ | ❌ |
down -v |
✅ | ✅ | ✅ | ❌ |
down --rmi all |
✅ | ✅ | ❌ | ✅ |
down -v --rmi all |
✅ | ✅ | ✅ | ✅ |
up vs start / down vs stop
| Command | What It Does |
|---|---|
docker compose up |
Creates AND starts containers |
docker compose start |
Starts existing stopped containers |
docker compose down |
Stops AND removes containers + networks |
docker compose stop |
Stops containers (doesn’t remove them) |
up ──→ Creates + Starts
(full setup)
start ──→ Starts only
(containers must exist)
stop ──→ Stops only
(containers still exist)
down ──→ Stops + Removes
(full cleanup)
The Daily Workflow
# Morning — start your dev stack
docker compose up -d
# Work all day — services running in background
docker compose ps
docker compose logs -f api
# Evening — stop everything
docker compose down
# Next morning — start fresh
docker compose up -d
# Volumes persist — your database data is still there!
Summary
| Command | Purpose | Removes |
|---|---|---|
up -d |
Create + start in background | — |
up --build |
Rebuild images + start | — |
down |
Stop + remove containers, networks | Containers, networks |
down -v |
Also remove volumes | + Volumes |
down --rmi all |
Also remove images | + Images |
Quick Reference
| Item | Detail |
|---|---|
| Start background | docker compose up -d |
| Start + rebuild | docker compose up –build |
| Stop + clean | docker compose down |
| Stop + clean + volumes | docker compose down -v |
| Stop + clean + images | docker compose down –rmi all |
| Start specific service | docker compose up -d web |