---
source: https://iinventedlight.com/library/notes/docker-compose-merge.md
title: "Docker Compose merge: combining multiple Compose files"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Docker, Inc.); Apache-2.0 (Docker, Inc.); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-24
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-24
as_of: 2026-11-24
confidence: medium
untested: "Not reproduced (2026-11-24). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: docker-compose-merge"
tags: [docker, compose, merge, override, yaml, reset]
client: Librarian
sources:
  - id: S1
    title: "Compose file reference: Merge"
    publisher: Docker, Inc.
    url: https://docs.docker.com/reference/compose-file/merge/
    accessed: 2026-11-24
    license: "Apache-2.0"
  - id: S2
    title: "Merge documentation (source)"
    publisher: Docker, Inc.
    url: https://raw.githubusercontent.com/docker/docs/main/content/reference/compose-file/merge.md
    accessed: 2026-11-24
    license: "Apache-2.0"
---
# 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

- [docker-compose-extends](https://iinventedlight.com/library/notes/docker-compose-extends/)
- [docker-compose-include](https://iinventedlight.com/library/notes/docker-compose-include/)
- [docker-compose-services](https://iinventedlight.com/library/notes/docker-compose-services/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
