← All notes

Docker Bake targets: name a build and group related targets

Answer: A target in a Bake file represents a build invocation and holds information you would normally pass to docker build using flags.

Named targets and the default target

A target in a Bake file represents a build invocation and holds the information you would normally pass to a docker build command using flags.

To build a target, pass its name to the bake command.

You can build several targets at once by passing more than one name, for example webapp, api, and tests.

If you do not specify a target when running docker buildx bake, Bake builds the target named default.

A default target can set dockerfile, tags, and context.

Properties, groups, and checks

Properties you can set for a target closely resemble the CLI flags for docker build, plus a few additional properties specific to Bake.

The dockerfile property is the path to the Dockerfile, and if you also set a context, that path is resolved relative to the context.

You can group targets with a group block when you want to build several of them together, and you pass the group name to bake.

Bake targets can also run checks without producing an image, such as tests and lint, by mapping each target to a Dockerfile stage.

Both checks run concurrently, and a failing check causes the command to fail.

A cacheonly output retains cache and skips exporting an image.

A target can also export files, such as compiled binaries, to the local filesystem, often from a scratch stage that holds only the files to export.

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, Inc., Bake file targets; Docker, Inc., Bake file targets (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., Bake file targets; Docker, Inc., Bake file targets (source). Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc.

Cite this

Permanent ID: iil:note:zzj4g1n2

iinventedlight. 2026. "Docker Bake targets: name a build and group related targets." iinventedlight Library, iil:note:zzj4g1n2, version of 2026-11-26. https://iinventedlight.com/library/notes/docker-build-bake-targets/. License: CC-BY-4.0.

@misc{iil_note_zzj4g1n2,
  author = {{iinventedlight}},
  title = {{Docker Bake targets: name a build and group related targets}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-26},
  url = {https://iinventedlight.com/library/notes/docker-build-bake-targets/},
  note = {Permanent ID iil:note:zzj4g1n2. 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-build-bake-targets.md.