Home Explore Blog CI



docker

1st chunk of `content/manuals/build/bake/_index.md`
7a911083641df8c9565057b189fb6e4460f49d0e7d33080f00000001000005bf
---
title: Bake
weight: 50
keywords: build, buildx, bake, buildkit, hcl, json, compose
aliases:
  - /build/customize/bake/
---

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:

```hcl {title=docker-bake.hcl}
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 = "{{% param "example_go_version" %}}"
  }
  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:

```console
$ 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](./introduction.md).

Title: Introduction to Docker Buildx Bake
Summary
Docker Buildx Bake allows defining build configurations declaratively using HCL, JSON, or YAML files (including Docker Compose). It enables concurrent builds through groups of targets, each specifying build context, Dockerfile, arguments, and tags. A simple command, `docker buildx bake`, initiates the build process based on the defined Bake file. The document points the reader to the Bake introduction page to get started.