Docker Engine 29 reference · Docker Compose

docker compose config Command (Docker CLI)

Validate the Compose files and print the final configuration after merging overrides and interpolating variables.

Docker Engine 29

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

docker compose config [OPTIONS] [SERVICE...]

Parameters

ParameterDescription
-q Only validate; print nothing if valid.
--services List service names.
--format json Output JSON.

Examples

See interpolated values
printf 'services:\n  api:\n    image: alpine:3.24\n    environment:\n      LEVEL: ${LOG_LEVEL:-info}\n' > compose.yaml
LOG_LEVEL=debug docker compose config --format json | python3 -c 'import json,sys; print(json.load(sys.stdin)["services"]["api"]["environment"])'

Output

{'LEVEL': 'debug'}

Run this on your computer — see “Get Started” for setup.

Validate a broken file
printf 'services:\n  api:\n    image: alpine:3.24\n    ports: [notaport]\n' > compose.yaml
docker compose config -q 2>&1 | head -1 | cut -c1-80 || true

Output

invalid containerPort: notaport

Run this on your computer — see “Get Started” for setup.

Was this page helpful?