Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

Docker Compose

Direct answer

Docker Compose defines multi-container applications in a compose.yaml (services, networks, volumes, environment) and manages them with docker compose up/down/logs.

When to use this

Use it to run multi-container stacks, or when a service in the stack fails.

First 30 seconds

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.

Operational verification

compose file → project network and volumes → services started in order → reachable by service name

Evidence · next step

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
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Scope / prerequisiteUse it to run multi-container stacks, or when a service in the stack fails.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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 references

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.

observation · 1
Key points

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.

Key checks
  • docker ps -a / podman ps -a — containers and state
  • docker logs <c> — container output
  • docker inspect <c> — configuration, mounts, network
  • docker 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), with compose.yml and the older docker-compose.yaml names 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, ps and logs manage 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

TaskCommand
Update images and recreate changed servicesdocker compose pull && docker compose up -d
Restart one servicedocker compose restart api
Run a one-off commanddocker compose run --rm api migrate
Stop and remove containers (volumes stay)docker compose down
Also remove volumesdocker compose down -v (data is lost)
Show the merged configurationdocker 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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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
Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

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%
Technical changelog & impact

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.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

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.

Aliases that resolve here
docker composecompose yamlmulti container docker
Embedded reference data

Quick lookup tables

Docker Compose operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for Docker Compose.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective stateDocker 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 verificationPin 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 chaincompose project/config → interpolation → service graph → image/build → networks/volumes → containers → dependency/readiness → application workloadTrace requested/configured state through effective state to the observed workload result.
Failure boundaryCompose 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 evidenceCorrelated Linux container/virtualization evidence can establish this proof path: compose project/config → interpolation → service graph → image/build → networks/volumes → containers → dependency/readiness → application workloadUse this observation only for the specific claim it actually supports.
Evidence limitIt 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 checkContinue 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 boundaryDocker Compose
Topic pathContainers → Docker Compose
Runtime stateDocker 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 chaincompose 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 boundaryCompose 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 ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?