Use it to run multi-container stacks, or when a service in the stack fails.
Docker Compose
Docker Compose defines multi-container applications in a compose.yaml (services, networks, volumes, environment) and manages them with docker compose up/down/logs.
1. docker compose config — merged, valid file.
2. docker compose ps — state of each service.
3. docker compose logs <svc>.
4. Dependencies healthy (healthcheck)?
5. Recreate after changes: docker compose up -d.
compose file → project network and volumes → services started in order → reachable by service name
For Containers → Docker Compose, continue with the first unproven Topic check: Pin exact host, runtime/hypervisor, object identity, source revision/image/definition and failing workload. If that boundary is healthy, advance to the adjacent check: Read back effective runtime state including process, namespace/resource or virtual-hardware boundaries. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
compose project/config → interpolation → service graph → image/build → networks/volumes → containers → dependency/readiness → application workload
Healthy evidence: resolved Compose config creates the intended service graph and all required dependencies reach usable state for the original application flow
Step 2 Verification and output interpretation Verify boundary
Verification chain. compose project/config → interpolation → service graph → image/build → networks/volumes → containers → dependency/readiness → application workload
Step 3 Commands Verify boundary
docker compose up -d
docker compose ps
docker compose logs -f web
docker compose config
Step 4 Failure modes and next checks Narrow the fault
Suspicious evidence: wrong project/env interpolation, stale containers, missing health semantics, dependency race or volume/network mismatch leaves a nominally started stack broken
Step 5 Common mistakes Narrow the fault
- Secrets in
compose.yaml.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Services reach each other by service name on the project network. depends_on with healthchecks controls start order. Use .env for variables and keep secrets out of the file.
docker ps -a / podman ps -a— containers and statedocker logs <c>— container outputdocker inspect <c>— configuration, mounts, networkdocker info— engine, storage driver, cgroup version
ReferenceImportant terms & boundaries5 sections · depth on demand
What this shows and what it does not
Compose command completion means requested objects were processed, but it does not show dependency readiness or application correctness.
In depth
Docker Compose: multi-container applications as code
Compose describes an application of several containers in one file, and manages them together. Docker's Compose application model defines the elements:
- The default file is
compose.yaml(preferred), withcompose.ymland the olderdocker-compose.yamlnames also accepted. - Services are the application's components.
- Networks connect services, volumes keep persistent data, and configs and secrets are mounted into containers as files.
- The project name groups the resources and isolates them from other projects.
docker compose up,down,psandlogsmanage the whole project.
A compose file for a small application
host$ cat /srv/reportapp/compose.yaml
name: reportapp
services:
db:
image: postgres:16
environment:
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
secrets: [db_password]
volumes: [pgdata:/var/lib/postgresql/data]
networks: [backend]
restart: unless-stopped
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"]
interval: 10s
api:
image: registry.example.net/report-api:1.4.2
depends_on:
db: {condition: service_healthy}
networks: [backend, frontend]
restart: unless-stopped
proxy:
image: nginx:1.27
ports: ["443:443"]
volumes: ["./nginx.conf:/etc/nginx/nginx.conf:ro"]
networks: [frontend]
restart: unless-stopped
volumes:
pgdata:
networks:
frontend:
backend:
internal: true
secrets:
db_password:
file: ./secrets/db_password.txt
host$ docker compose config --quiet && echo valid
host$ docker compose up -d
host$ docker compose ps
host$ docker compose logs -f --tail 50 api
Operating a compose project
| Task | Command |
|---|---|
| Update images and recreate changed services | docker compose pull && docker compose up -d |
| Restart one service | docker compose restart api |
| Run a one-off command | docker compose run --rm api migrate |
| Stop and remove containers (volumes stay) | docker compose down |
| Also remove volumes | docker compose down -v (data is lost) |
| Show the merged configuration | docker compose config |
Secrets as files
The database password comes from a file, mounted at /run/secrets/db_password, instead of a plain environment variable. Environment variables show up in docker inspect and in process listings. Keep secrets/ out of version control, with mode 600 on the host.
Documented example, not captured output.
How it works at runtime
Docker Compose is part of Containers → Docker Compose. Docker Compose defines a multi-container application graph of services, images, networks, volumes, dependencies, environment and lifecycle operations.
Topic-specific state model. Docker Compose defines a multi-container application graph of services, images, networks, volumes, dependencies, environment and lifecycle operations.
Quick reference
Docker Compose describes multi-container applications in compose.yaml:
services:
db:
image: postgres:16
environment:
POSTGRES_PASSWORD_FILE: /run/secrets/db_pw
secrets: [db_pw]
volumes: [pgdata:/var/lib/postgresql/data]
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
app:
image: registry.example.com/app:1.4.2
depends_on:
db: { condition: service_healthy }
ports: ["127.0.0.1:8080:8080"]
restart: unless-stopped
volumes: { pgdata: {} }
secrets: { db_pw: { file: ./db_pw.txt } }
docker compose up -d; docker compose ps; docker compose logs -f app
docker compose pull && docker compose up -d # update
Limits and how it fails
Primary failure point. Compose command completion means requested objects were processed, but it does not show dependency readiness or application correctness.
Snapshot/image existence is not a verified backup.
ReferenceConfiguration & state1 section · depth on demand
Configuration, persistence and lifecycle
Distribution/platform context. Docker Compose owns project-level orchestration on one Docker environment; CI/CD and broader orchestration remain separate.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Containers → Docker Compose. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.docker.com/engine/ · confidence 94%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Docker Compose operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for Docker Compose.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | Docker Compose defines a multi-container application graph of services, images, networks, volumes, dependencies, environment and lifecycle operations. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin host + object identity + source image/definition → verify host/runtime capability → read back effective process/namespace/cgroup or virtual-hardware state → verify storage/network attachments → verify guest/container readiness → repeat original workload + regression check. | Use the shortest evidence path first; a fast check is a boundary test, not blanket proof. |
| Verification chain | compose project/config → interpolation → service graph → image/build → networks/volumes → containers → dependency/readiness → application workload | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | Compose command completion means requested objects were processed; it does not prove dependency readiness or application correctness. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated Linux container/virtualization evidence can establish this proof path: compose project/config → interpolation → service graph → image/build → networks/volumes → containers → dependency/readiness → application workload | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It does not independently prove unobserved clients, names, identities, routes, sessions, backends or time periods. Compose command completion means requested objects were processed; it does not prove dependency readiness or application correctness. | Do not promote a local success signal into end-to-end or adjacent-dependency proof. |
| Next troubleshooting check | Continue from the first unproven runtime boundary, capture adjacent host/object/resource/attachment evidence, make only the demonstrated persistent change, then repeat the original workload plus a regression check. | Continue to the next unresolved boundary while preserving the original test condition. |
Docker Compose · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | Docker Compose |
|---|---|
| Topic path | Containers → Docker Compose |
| Runtime state | Docker Compose defines a multi-container application graph of services, images, networks, volumes, dependencies, environment and lifecycle operations. |
| Fast checks | - Pin exact host, runtime/hypervisor, object identity, source revision/image/definition and failing workload. - Read back effective runtime state including process, namespace/resource or virtual-hardware boundaries. - Trace storage and network attachments plus readiness from the real client or dependent workload path. - Apply the smallest persistent change, then repeat the original workload and an adjacent regression check. |
| Verification chain | compose project/config → interpolation → service graph → image/build → networks/volumes → containers → dependency/readiness → application workload Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. |
| Failure boundary | Compose command completion means requested objects were processed; it does not prove dependency readiness or application correctness. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |