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, stop, rebuild, and inspect a Compose project.

Start services in foreground

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

bashANYdockercomposeuplifecycle
bash
docker compose up

Use this for the default local startup flow.

Start services in background

Run the full stack in detached mode.

bashANYdockercomposeupdetached
bash
docker compose up -d

Useful for long-running local environments.

Build and start services

Rebuild images before starting containers.

bashANYdockercomposebuildup
bash
docker compose up --build

Useful when Dockerfiles or build contexts changed.

Stop and remove resources

Stops containers and removes project networks.

bashANYdockercomposedown
bash
docker compose down

Leaves named volumes unless you add `-v`.

Stop and remove volumes

Removes containers, networks, and named volumes.

bashANYdockercomposedownvolumes
bash
docker compose down -v

Use carefully because stateful data will be deleted.

Start existing containers

Starts previously created services without recreating them.

bashANYdockercomposestart
bash
docker compose start

Useful after `docker compose stop`.

Stop running services

Gracefully stops running containers in the project.

bashANYdockercomposestop
bash
docker compose stop

Containers remain available for `start` later.

Restart services

Restarts one or more service containers.

bashANYdockercomposerestart
bash
docker compose restart

Useful after config changes external to the image.

Pause services

Pauses running containers in the project.

bashANYdockercomposepause
bash
docker compose pause

Suspends processes without stopping the containers.

Unpause services

Resumes paused containers.

bashANYdockercomposeunpause
bash
docker compose unpause

Pair with `pause` during testing.

Build and Images

Build, pull, and push service images.

Build service images

Builds images for services with a `build` section.

bashANYdockercomposebuild
bash
docker compose build

Great when working from source.

Build without cache

Forces a clean rebuild without cached layers.

bashANYdockercomposebuildno-cache
bash
docker compose build --no-cache

Useful when debugging build issues.

Build one service

Builds only the selected service.

bashANYdockercomposebuildservice
bash
docker compose build web

Speeds up iteration on a single app container.

Pull service images

Downloads images for services that use `image:`.

bashANYdockercomposepull
bash
docker compose pull

Useful before a deployment or refresh.

Pull while skipping buildable services

Pulls only pure image-based services.

bashANYdockercomposepull
bash
docker compose pull --ignore-buildable

Handy in mixed build/image projects.

Push built images

Pushes service images to their configured registries.

bashANYdockercomposepush
bash
docker compose push

Useful in CI after a successful build.

List project images

Shows images used by the current project.

bashANYdockercomposeimages
bash
docker compose images

Useful for audit and cleanup work.

Logs, Exec, and Shell Access

Inspect output and run commands inside services.

Show logs

Prints aggregated logs for the project.

bashANYdockercomposelogs
bash
docker compose logs

Use service names to narrow the output.

Follow logs

Streams live logs from services.

bashANYdockercomposelogsfollow
bash
docker compose logs -f

Helpful during startup and debugging.

Tail logs for one service

Shows only recent log lines for a service.

bashANYdockercomposelogstail
bash
docker compose logs --tail=100 web

Keeps output focused during triage.

Open shell in running service

Executes a shell inside an already-running service container.

bashANYdockercomposeexecshell
bash
docker compose exec web sh

Use `bash` when the image includes it.

Open bash in running service

Runs Bash inside the running service container.

bashANYdockercomposeexecbash
bash
docker compose exec web bash

Common in Debian/Ubuntu based app images.

Run one-off command

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

bashANYdockercomposerunone-off
bash
docker compose run --rm web python manage.py migrate

Useful for migrations, tests, or generators.

Show running processes

Displays processes running inside service containers.

bashANYdockercomposetop
bash
docker compose top

Helpful when debugging process models and daemons.

List project containers

Shows containers and status for the project.

bashANYdockercomposeps
bash
docker compose ps

Use `-a` to include stopped containers.

Stream project events

Streams container lifecycle events for the project.

bashANYdockercomposeevents
bash
docker compose events

Useful for debugging restarts and recreate loops.

Inspection and Cleanup

Inspect config, dependencies, and remove stale resources.

Render normalized config

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

bashANYdockercomposeconfig
bash
docker compose config

Use this to verify what Compose will actually run.

List service names

Prints all services in the effective config.

bashANYdockercomposeconfigservices
bash
docker compose config --services

Useful in scripts and CI checks.

List named volumes

Shows named volumes declared in the effective config.

bashANYdockercomposeconfigvolumes
bash
docker compose config --volumes

Helps audit stateful resources.

List profiles

Shows all profiles used in the project.

bashANYdockercomposeconfigprofiles
bash
docker compose config --profiles

Helpful when organizing optional services.

List compose projects

Lists active and recent Compose projects on the host.

bashANYdockercomposels
bash
docker compose ls

Useful when you run many stacks locally.

Remove stopped containers

Removes stopped service containers.

bashANYdockercomposerm
bash
docker compose rm

Useful after experimenting with one-off runs.

Force kill services

Immediately stops containers with a signal.

bashANYdockercomposekill
bash
docker compose kill

Useful when graceful stop is hanging.

Wait for services to stop

Waits until selected services stop and returns their exit codes.

bashANYdockercomposewait
bash
docker compose wait

Useful in automation and test pipelines.

Recommended next

No recommendations yet.