docker buildkit

Core Idea

Bake is the declarative side of docker build: one bake file (HCL, YAML, or JSON) describes every image and platform target, and one docker buildx bake command builds them all.

  • Built into the Buildx CLI, so docker buildx bake is available wherever Buildx is.
  • Replaces long repeatable docker build invocations with a file you version and share.
  • The note carries an article series and a Docker Docs deep dive.

Buildx bake deep dive: Bake all your images with one command
🌟 Bake file reference | Docker Docs
[!video]- Docker Bake

Docker bake is the declarative approach for docker build command.
Bake is a command built into the Buildx CLI, so as long as you have Buildx installed, you also have access to bake, via the docker buildx bake command.

Docker bake file support HCL, YAML, or JSON.

docker build \
  -f Dockerfile \
  -t myapp:latest \
  --build-arg foo=bar \
  --no-cache \
  --platform linux/amd64,linux/arm64 \
  .
target "myapp" {
  context = "."
  dockerfile = "Dockerfile"
  tags = ["myapp:latest"]
  args = {
    foo = "bar"
  }
  no-cache = true
  platforms = ["linux/amd64", "linux/arm64"]
}
  • target in a Bake file represents a build invocation.
    • docker buildx bake myapp
  • default target
target "default" {
  dockerfile = "webapp.Dockerfile"
  tags = ["docker.io/username/webapp:latest"]
  context = "https://github.com/username/webapp"
}

docker buildx bake

Docker Bake Article Series