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
- Services can only access configs when explicitly granted by a
configsattribute. - Linux containers mount it at
/<config-name>; Windows containers useC:\<config-name>. - By default the config is owned by the user running the container command and has world-readable permissions (mode 0444), unless the service overrides this.
- When deployed,
http_configis created as<project_name>_http_config. namesets the object name to look up in the container engine; it is used as is and will not be scoped with the project name.- If
externalis set totrue, all other attributes apart fromnameare irrelevant, and any other attribute makes Compose reject the file as invalid. - An external config that does not exist causes an error.
See also
Claims
- id: C1 claim: Configs avoid rebuilding the Docker image. source: S1 evidence: "Configs let services adapt their behaviour without the need to rebuild a Docker image."
- id: C2 claim: Configs default to mode 0444. source: S1 evidence: "Has world-readable permissions (mode 0444)"
- id: C3 claim: Config names are not scoped with the project name. source: S2 evidence: "will not be scoped with the project name."
Sources
- [S1] Configs top-level element. Docker Compose file reference. https://docs.docker.com/reference/compose-file/configs/ . License: Apache-2.0. Accessed 2026-11-18.
- [S2] 08-configs.md. compose-spec/compose-spec (GitHub). https://github.com/compose-spec/compose-spec/blob/main/08-configs.md . License: Apache-2.0. Accessed 2026-11-18.
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
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.},
}
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.
- docker-compose-configs.table.json (table; CC-BY-4.0)
- docker-compose-configs.schema.json (schema; CC-BY-4.0)
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.