← All notes

Compose build: declare how a service image is built

Answer: The optional build key describes, in a portable Compose file, how to rebuild an application from source.

String or object

You may give build as a context path string, or as a detailed build definition.

A string path becomes the Docker context for the build.

Compose then expects a canonical Dockerfile at the directory root.

A detailed object can name build arguments and an alternate Dockerfile location.

Paths

Paths may be absolute or relative in either form.

Relative paths start from the directory that contains the Compose file.

An absolute path is not portable, and Compose displays a warning.

The spec also explains using build and image together.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker Docs, Compose Build Specification; Docker documentation source, Compose Build Specification (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 Docs, Compose Build Specification; Docker documentation source, Compose Build Specification (source). Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc.

Cite this

Permanent ID: iil:note:78jdjq5h

iinventedlight. 2026. "Compose build: declare how a service image is built." iinventedlight Library, iil:note:78jdjq5h, version of 2026-11-24. https://iinventedlight.com/library/notes/docker-compose-build/. License: CC-BY-4.0.

@misc{iil_note_78jdjq5h,
  author = {{iinventedlight}},
  title = {{Compose build: declare how a service image is built}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-24},
  url = {https://iinventedlight.com/library/notes/docker-compose-build/},
  note = {Permanent ID iil:note:78jdjq5h. License: CC-BY-4.0.},
}

Markdown

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.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/docker-compose-build.md.