DevOps & Infrastructure

Use docker compose config Before Deploying

Render the Compose model before deployment to catch interpolation, merge, profile, and path surprises.

2 min read
#docker compose#configuration#deployment#validation

An aerial view of a wide beach and coastline

Photo: Unsplash.

The Compose file you read is not always the model Docker receives. Variables are interpolated, multiple files are merged, short syntax is expanded, and profiles can change what is active.

Render the result before deployment:

docker compose --env-file .env.production \
  -f compose.yaml \
  -f compose.production.yaml \
  config

This catches invalid structure and makes overrides visible. Pay particular attention to image tags, published ports, volume targets, command arrays, and environment values.

Do not paste the output into tickets or public CI logs: the rendered model may contain interpolated secrets. When you only need an image list, ask for that directly:

docker compose -f compose.yaml -f compose.production.yaml config --images

To check service names:

docker compose -f compose.yaml -f compose.production.yaml config --services

You can validate without printing the rendered configuration:

docker compose config --quiet

One common surprise is an unset variable becoming an empty string. Use required-value interpolation for settings that must never be empty:

services:
  app:
    image: "registry.example.com/app:${APP_VERSION:?set APP_VERSION}"

Run the same command in CI with the same file order and environment contract used by deployment. It will not prove that the containers work, but it closes the gap between the YAML you intended and the configuration Compose actually assembled.

Reference