← All notes

Docker Compose configs - mount config files into services without rebuilding the image

Answer: Declare the config under the top-level configs element (from a file, environment, inline content, or external), then grant it in the service's configs list. Configs let services adapt their behaviour without the need to rebuild a Docker image, and are mounted as files at /<config-name> by default.

Example

services:
  web:
    image: httpd:latest
    configs:
      - http_config
      - app_config
configs:
  http_config:
    file: ./httpd.conf
  app_config:
    content: |
      debug=${DEBUG}
      spring.application.name=${COMPOSE_PROJECT_NAME}
  simple_config:
    environment: "SIMPLE_CONFIG_VALUE"
  shared_config:
    external: true
    name: "${HTTP_CONFIG_KEY}"

Sources

| Source | Content | |---|---| | file | the contents of the file at the specified path | | environment | the value of an environment variable (Compose 2.23.1+) | | content | the inlined value, with variables interpolated (Compose 2.23.1+) | | external: true | a config that has already been created; Compose does not attempt to create it |

Defaults and rules

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker Compose file reference, Configs top-level element; compose-spec/compose-spec (GitHub), 08-configs.md. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Apache-2.0 (https://raw.githubusercontent.com/compose-spec/compose-spec/main/LICENSE). Copyright The Compose Specification Authors. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Docker Compose file reference, Configs top-level element; compose-spec/compose-spec (GitHub), 08-configs.md. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Apache-2.0 (https://raw.githubusercontent.com/compose-spec/compose-spec/main/LICENSE). Copyright The Compose Specification Authors.

Cite this

Permanent ID: iil:note:xf6zjt16

iinventedlight. 2026. "Docker Compose configs - mount config files into services without rebuilding the image." iinventedlight Library, iil:note:xf6zjt16, version of 2026-11-18. https://iinventedlight.com/library/notes/docker-compose-configs/. License: CC-BY-4.0.

@misc{iil_note_xf6zjt16,
  author = {{iinventedlight}},
  title = {{Docker Compose configs - mount config files into services without rebuilding the image}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/docker-compose-configs/},
  note = {Permanent ID iil:note:xf6zjt16. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/docker-compose-configs.md.