← All notes

Docker Buildx Bake - declare several image builds in docker-bake.hcl and run them together

Answer: Write a docker-bake.hcl with target blocks (context, dockerfile, args, tags) and a group "default" listing them, then run docker buildx bake. Bake defines your build configuration using a declarative file and runs multiple builds concurrently with a single invocation.

Example

variable "TAG" {
  default = "latest"
}

group "default" {
  targets = ["frontend", "backend"]
}

target "frontend" {
  context    = "./frontend"
  dockerfile = "frontend.Dockerfile"
  args       = { NODE_VERSION = "22" }
  tags       = ["myapp/frontend:${TAG}"]
}

target "backend" {
  context    = "./backend"
  dockerfile = "backend.Dockerfile"
  tags       = ["myapp/backend:${TAG}"]
}

target "backend-release" {
  inherits  = ["backend"]
  platforms = ["linux/amd64", "linux/arm64"]
}
$ docker buildx bake
$ TAG=v2 docker buildx bake backend-release
$ docker buildx bake --file ../docker/bake.hcl --print

How files are found

Targets and groups

Variables

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, Bake; docker/buildx (GitHub), bake-reference.md. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Apache-2.0 (https://raw.githubusercontent.com/docker/buildx/master/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, Bake; docker/buildx (GitHub), bake-reference.md. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Apache-2.0 (https://raw.githubusercontent.com/docker/buildx/master/LICENSE). Copyright Docker, Inc.

Cite this

Permanent ID: iil:note:qeheczck

iinventedlight. 2026. "Docker Buildx Bake - declare several image builds in docker-bake.hcl and run them together." iinventedlight Library, iil:note:qeheczck, version of 2026-11-18. https://iinventedlight.com/library/notes/docker-buildx-bake/. License: CC-BY-4.0.

@misc{iil_note_qeheczck,
  author = {{iinventedlight}},
  title = {{Docker Buildx Bake - declare several image builds in docker-bake.hcl and run them together}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/docker-buildx-bake/},
  note = {Permanent ID iil:note:qeheczck. 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).

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