Docker Compose merge: combining multiple Compose files
Answer: Compose can define one application model through multiple Compose files.
Mappings and sequences
When several files are used, Compose follows fixed rules to merge them.
A YAML mapping is merged by adding missing entries and merging the conflicting ones.
A YAML sequence is merged by appending values from the overriding file.
Shell command attributes such as command, entrypoint, and healthcheck test are replaced, not appended.
Resets and unique resources
Ports, volumes, secrets, and configs merge by a unique key rather than a blind append.
The custom YAML tag reset can clear a value set by the overridden file.
A valid value must still be provided for reset, but that value is ignored.
The target attribute then gets the type's default value or null.
See also
Claims
- id: C1 claim: Compose can define one application model through multiple Compose files. source: S1 evidence: "define a Compose application model through multiple Compose files"
- id: C2 claim: A YAML mapping is merged by adding missing entries and merging conflicts. source: S1 evidence: "mapping gets merged by adding missing entries and merging the conflicting ones"
- id: C3 claim: A YAML sequence is merged by appending values from the overriding file. source: S1 evidence: "sequence is merged by appending values from the overriding Compose file"
- id: C4 claim: The reset tag can override a value set by the overridden Compose file. source: S2 evidence: "override a value set by the overridden Compose file"
Sources
- [S1] Compose file reference: Merge. Docker, Inc.. https://docs.docker.com/reference/compose-file/merge/ . License: Apache-2.0. Accessed 2026-11-24.
- [S2] Merge documentation (source). Docker, Inc.. https://raw.githubusercontent.com/docker/docs/main/content/reference/compose-file/merge.md . License: Apache-2.0. Accessed 2026-11-24.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker, Inc., Compose file reference: Merge; Docker, Inc., Merge documentation (source). Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Docker, Inc., Compose file reference: Merge; Docker, Inc., Merge documentation (source). Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc.
Cite this
iinventedlight. 2026. "Docker Compose merge: combining multiple Compose files." iinventedlight Library, iil:note:m32dj9db, version of 2026-11-24. https://iinventedlight.com/library/notes/docker-compose-merge/. License: CC-BY-4.0.
@misc{iil_note_m32dj9db,
author = {{iinventedlight}},
title = {{Docker Compose merge: combining multiple Compose files}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-24},
url = {https://iinventedlight.com/library/notes/docker-compose-merge/},
note = {Permanent ID iil:note:m32dj9db. 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-merge.schema.json (schema; CC-BY-4.0)
- docker-compose-merge.table.json (table; 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-merge.md.