Docker Compose extensions: reusable x- fields in a Compose file
Answer: Extensions can also be used with anchors and aliases.
The x- prefix
Use the prefix x- to modularize configurations you want to reuse.
They can appear in any structure where user-defined keys are not expected.
Duration values are written as a string in the form of a value then a unit.
The supported units are us, ms, s, m, and h.
Where they may appear
Values can combine multiple units without a separator.
This is the sole exception where Compose silently ignores unrecognized fields.
This defines a new node which contains the environment field.
Compose ignores any fields that start with x-.
See also
Claims
- id: C1 claim: Use the prefix x- to modularize configurations you want to reuse. source: S1 evidence: "prefix x- as a top-level element to modularize"
- id: C2 claim: Compose ignores any fields that start with x-. source: S1 evidence: "ignores any fields that start with x-"
- id: C3 claim: This is the sole exception where unrecognized fields are silently ignored. source: S1 evidence: "sole exception where Compose silently ignores unrecognized fields"
- id: C4 claim: Extensions can also appear where user-defined keys are not expected. source: S2 evidence: "within any structure in a Compose file where user-defined keys are not expected"
Sources
- [S1] Compose file reference: Extensions. Docker, Inc.. https://docs.docker.com/reference/compose-file/extension/ . License: Apache-2.0. Accessed 2026-11-24.
- [S2] Extensions documentation (source). Docker, Inc.. https://raw.githubusercontent.com/docker/docs/main/content/reference/compose-file/extension.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: Extensions; Docker, Inc., Extensions 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: Extensions; Docker, Inc., Extensions documentation (source). Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc.
Cite this
iinventedlight. 2026. "Docker Compose extensions: reusable x- fields in a Compose file." iinventedlight Library, iil:note:pe7bjkd6, version of 2026-11-24. https://iinventedlight.com/library/notes/docker-compose-extension/. License: CC-BY-4.0.
@misc{iil_note_pe7bjkd6,
author = {{iinventedlight}},
title = {{Docker Compose extensions: reusable x- fields in a Compose file}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-24},
url = {https://iinventedlight.com/library/notes/docker-compose-extension/},
note = {Permanent ID iil:note:pe7bjkd6. 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-extension.schema.json (schema; CC-BY-4.0)
- docker-compose-extension.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-extension.md.