Scroll to navigation

DOCKER-BUILDX-BAKE(1) DOCKER-BUILDX-BAKE(1)

NAME

docker-buildx-bake - Build from a file

SYNOPSIS

docker buildx bake [OPTIONS] [TARGET...]

DESCRIPTION

Bake is a high-level build command. Each specified target runs in parallel as part of the build.

Read High-level build options with Bake ⟨/build/bake/⟩ guide for introduction to writing bake files.

Note

buildx bake command may receive backwards incompatible features in the future if needed. We are looking for feedback on improving the command and extending the functionality further.

OPTIONS

-f, --file=[] Build definition file

-h, --help[=false] help for bake

--load[=false] Shorthand for "--set=*.output=type=docker"

--metadata-file="" Write build result metadata to the file

--no-cache[=false] Do not use cache when building the image

--print[=false] Print the options without building

--progress="auto" Set type of progress output ("auto", "plain", "tty"). Use plain to show container output

--provenance="" Shorthand for "--set=*.attest=type=provenance"

--pull[=false] Always attempt to pull all referenced images

--push[=false] Shorthand for "--set=*.output=type=registry"

--sbom="" Shorthand for "--set=*.attest=type=sbom"

--set=[] Override target value (e.g., "targetpattern.key=value")

OPTIONS INHERITED FROM PARENT COMMANDS

--builder="" Override the configured builder instance

EXAMPLE

### Override the configured builder instance (--builder) {#builder}
Same as [`buildx --builder`](/reference/cli/docker/buildx/#builder).
### Specify a build definition file (-f, --file) {#file}
Use the `-f` / `--file` option to specify the build definition file to use.
The file can be an HCL, JSON or Compose file. If multiple files are specified,
all are read and the build configurations are combined.
You can pass the names of the targets to build, to build only specific target(s).
The following example builds the `db` and `webapp-release` targets that are
defined in the `docker-bake.dev.hcl` file:
```hcl
# docker-bake.dev.hcl
group "default" {

targets = ["db", "webapp-dev"] } target "webapp-dev" {
dockerfile = "Dockerfile.webapp"
tags = ["docker.io/username/webapp"] } target "webapp-release" {
inherits = ["webapp-dev"]
platforms = ["linux/amd64", "linux/arm64"] } target "db" {
dockerfile = "Dockerfile.db"
tags = ["docker.io/username/db"] }

$ docker buildx bake -f docker-bake.dev.hcl db webapp-release

See the Bake file reference ⟨/build/bake/reference/⟩ for more details.

Don't use cache when building the image (--no-cache) {#no-cache}

Same as build --no-cache. Don't use cache when building the image.

Prints the resulting options of the targets desired to be built, in a JSON format, without starting a build.

$ docker buildx bake -f docker-bake.hcl --print db
{

"group": {
"default": {
"targets": [
"db"
]
}
},
"target": {
"db": {
"context": "./",
"dockerfile": "Dockerfile",
"tags": [
"docker.io/tiborvass/db"
]
}
} }

Set type of progress output (--progress) {#progress}

Same as ⟨/reference/cli/docker/buildx/build/#progress⟩.

Create provenance attestations (--provenance) {#provenance}

Same as ⟨/reference/cli/docker/buildx/build/#provenance⟩.

Always attempt to pull a newer version of the image (--pull) {#pull}

Same as build --pull.

Create SBOM attestations (--sbom) {#sbom}

Same as ⟨/reference/cli/docker/buildx/build/#sbom⟩.

Override target configurations from command line (--set) {#set}

--set targetpattern.key[.subkey]=value

Override target configurations from command line. The pattern matching syntax is defined in https://golang.org/pkg/path/#Match.

$ docker buildx bake --set target.args.mybuildarg=value
$ docker buildx bake --set target.platform=linux/arm64
$ docker buildx bake --set foo*.args.mybuildarg=value # overrides build arg for all targets starting with 'foo'
$ docker buildx bake --set *.platform=linux/arm64     # overrides platform for all targets
$ docker buildx bake --set foo*.no-cache              # bypass caching only for targets starting with 'foo'

You can override the following fields:

  • args
  • cache-from
  • cache-to
  • context
  • dockerfile
  • labels
  • no-cache
  • no-cache-filter
  • output
  • platform
  • pull
  • push
  • secrets
  • ssh
  • tags
  • target ``` # SEE ALSO docker-buildx(1)

Feb 2025