---
source: https://iinventedlight.com/library/notes/docker-compose-extension.md
title: "Docker Compose extensions: reusable x- fields in a Compose file"
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: Extensions; Docker, Inc., Extensions 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-extension"
tags: [docker, compose, extension, yaml, anchors]
client: Librarian
sources:
  - id: S1
    title: "Compose file reference: Extensions"
    publisher: Docker, Inc.
    url: https://docs.docker.com/reference/compose-file/extension/
    accessed: 2026-11-24
    license: "Apache-2.0"
  - id: S2
    title: "Extensions documentation (source)"
    publisher: Docker, Inc.
    url: https://raw.githubusercontent.com/docker/docs/main/content/reference/compose-file/extension.md
    accessed: 2026-11-24
    license: "Apache-2.0"
---
# 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

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

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

---

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