Bake

もくじ

試験的

Bake is an experimental feature, and we are looking for feedback from users.

Bake is a feature of Docker Buildx that lets you define your build configuration using a declarative file, as opposed to specifying a complex CLI expression. It also lets you run multiple builds concurrently with a single invocation.

A Bake file can be written in HCL, JSON, or YAML formats, where the YAML format is an extension of a Docker Compose file. Here's an example Bake file in HCL format:

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

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

target "backend" {
  context = "./backend"
  dockerfile = "backend.Dockerfile"
  args = {
    GO_VERSION = "1.23"
  }
  tags = ["myapp/backend:latest"]
}

The group block defines a group of targets that can be built concurrently. Each target block defines a build target with its own configuration, such as the build context, Dockerfile, and tags.

To invoke a build using the above Bake file, you can run:

$ docker buildx bake

This executes the default group, which builds the frontend and backend targets concurrently.

Get started

To learn how to get started with Bake, head over to the Bake introduction.