---
source: https://iinventedlight.com/library/notes/docker-build-bake-targets.md
title: "Docker Bake targets: name a build and group related targets"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache License 2.0 (Docker, Inc.); Apache License 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., Bake file targets; Docker, Inc., Bake file targets (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-26
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-26
as_of: 2026-11-26
confidence: medium
untested: "Not reproduced (2026-11-26). 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-build-bake-targets"
tags: [docker, bake, buildx, targets, dockerfile]
client: Librarian
sources:
  - id: S1
    title: "Bake file targets"
    publisher: Docker, Inc.
    url: https://docs.docker.com/build/bake/targets/
    accessed: 2026-11-26
    license: "Apache License 2.0"
  - id: S2
    title: "Bake file targets (source)"
    publisher: Docker, Inc.
    url: https://raw.githubusercontent.com/docker/docs/main/content/manuals/build/bake/targets.md
    accessed: 2026-11-26
    license: "Apache License 2.0"
---
# 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

- [docker-build-bake-overrides](https://iinventedlight.com/library/notes/docker-build-bake-overrides/)
- [docker-buildx-bake](https://iinventedlight.com/library/notes/docker-buildx-bake/)
- [docker-build-exporters](https://iinventedlight.com/library/notes/docker-build-exporters/)

## Claims

- id: C1
  claim: A Bake target represents one build and holds the flags you would pass to docker build.
  source: S1
  evidence: "A target in a Bake file represents a build invocation."

- id: C2
  claim: If no target is named, Bake builds the target called default.
  source: S1
  evidence: "bake will build the target named default"

- id: C3
  claim: A cacheonly output retains cache and skips exporting an image.
  source: S2
  evidence: "keeps the build cache without exporting an image."

## Sources

- [S1] Bake file targets. Docker, Inc.. https://docs.docker.com/build/bake/targets/ . License: Apache License 2.0. Accessed 2026-11-26.

- [S2] Bake file targets (source). Docker, Inc.. https://raw.githubusercontent.com/docker/docs/main/content/manuals/build/bake/targets.md . License: Apache License 2.0. Accessed 2026-11-26.

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.

---

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