Docker Compose Cheat Sheet

Commands for starting, stopping, inspecting, and operating Docker Compose projects.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Project Lifecycle
Start services in foreground
docker compose up

# Builds, creates, and starts all services defined in the Compose project.

Start services in background
docker compose up -d

# Run the full stack in detached mode.

Build and start services
docker compose up --build

# Rebuild images before starting containers.

Stop and remove resources
docker compose down

# Stops containers and removes project networks.

Stop and remove volumes
docker compose down -v

# Removes containers, networks, and named volumes.

Start existing containers
docker compose start

# Starts previously created services without recreating them.

Stop running services
docker compose stop

# Gracefully stops running containers in the project.

Restart services
docker compose restart

# Restarts one or more service containers.

Pause services
docker compose pause

# Pauses running containers in the project.

Unpause services
docker compose unpause

# Resumes paused containers.

## Build and Images
Build service images
docker compose build

# Builds images for services with a `build` section.

Build without cache
docker compose build --no-cache

# Forces a clean rebuild without cached layers.

Build one service
docker compose build web

# Builds only the selected service.

Pull service images
docker compose pull

# Downloads images for services that use `image:`.

Pull while skipping buildable services
docker compose pull --ignore-buildable

# Pulls only pure image-based services.

Push built images
docker compose push

# Pushes service images to their configured registries.

List project images
docker compose images

# Shows images used by the current project.

## Logs, Exec, and Shell Access
Show logs
docker compose logs

# Prints aggregated logs for the project.

Follow logs
docker compose logs -f

# Streams live logs from services.

Tail logs for one service
docker compose logs --tail=100 web

# Shows only recent log lines for a service.

Open shell in running service
docker compose exec web sh

# Executes a shell inside an already-running service container.

Open bash in running service
docker compose exec web bash

# Runs Bash inside the running service container.

Run one-off command
docker compose run --rm web python manage.py migrate

# Starts a fresh container for a one-off task and removes it after exit.

Show running processes
docker compose top

# Displays processes running inside service containers.

List project containers
docker compose ps

# Shows containers and status for the project.

Stream project events
docker compose events

# Streams container lifecycle events for the project.

## Inspection and Cleanup
Render normalized config
docker compose config

# Merges files, interpolates variables, and prints the final Compose model.

List service names
docker compose config --services

# Prints all services in the effective config.

List named volumes
docker compose config --volumes

# Shows named volumes declared in the effective config.

List profiles
docker compose config --profiles

# Shows all profiles used in the project.

List compose projects
docker compose ls

# Lists active and recent Compose projects on the host.

Remove stopped containers
docker compose rm

# Removes stopped service containers.

Force kill services
docker compose kill

# Immediately stops containers with a signal.

Wait for services to stop
docker compose wait

# Waits until selected services stop and returns their exit codes.

Recommended next

No recommendations yet.