Docker Buildx Cheat Sheet

Modern BuildKit and Buildx reference for multi-platform builds, cache, secrets, and remote outputs.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Buildx Basics

Modern BuildKit-powered multi-platform build workflows.

Show Buildx version

Show Buildx version and component details.

bashANYbuildxversion
bash
docker buildx version

Useful to confirm feature availability.

List builders

List available builders and supported platforms.

bashANYbuildxbuilders
bash
docker buildx ls

Helpful for checking which builder is active and what it can build.

Create a builder

Create and switch to a new builder instance.

bashANYbuildxbuilders
bash
docker buildx create --name multiarch --use

Common first step for multi-platform builds.

Inspect current builder

Inspect and bootstrap a builder.

bashANYbuildxbuildersinspect
bash
docker buildx inspect --bootstrap

Shows driver, nodes, and platform support.

Use a builder

Switch to a named builder.

bashANYbuildxbuilders
bash
docker buildx use multiarch

Useful when you maintain separate local and CI builders.

Remove a builder

Delete a builder instance.

bashANYbuildxbuilderscleanup
bash
docker buildx rm multiarch

Cleanup after experiments or when rotating build nodes.

Buildx Build Workflows

Multi-platform builds, outputs, caching, and provenance.

Build with Buildx

Build using Buildx and BuildKit.

bashANYbuildxbuild
bash
docker buildx build -t ghcr.io/acme/myapp:dev .

This is the modern build command for advanced workflows.

Build and load into local daemon

Build and load the result into the local Docker image store.

bashANYbuildxbuildlocal
bash
docker buildx build --load -t myapp:dev .

Useful for single-platform local testing.

Build and push directly

Build and push the image directly to a registry.

bashANYbuildxbuildregistry
bash
docker buildx build --push -t ghcr.io/acme/myapp:1.0.0 .

Common in CI where the local daemon store is not needed.

Build multi-platform image

Build and publish a multi-platform image.

bashANYbuildxmultiarchbuild
bash
docker buildx build --platform linux/amd64,linux/arm64 --push -t ghcr.io/acme/myapp:1.0.0 .

Clients pull the matching platform automatically.

Build target stage with Buildx

Build a specific stage using Buildx.

bashANYbuildxbuildmultistage
bash
docker buildx build --target build --load -t myapp:build .

Useful with multi-stage Dockerfiles and advanced builders.

Use registry cache

Use a remote registry cache for faster CI builds.

bashANYbuildxcacheci
bash
docker buildx build --cache-from type=registry,ref=ghcr.io/acme/myapp:cache --cache-to type=registry,ref=ghcr.io/acme/myapp:cache,mode=max --push -t ghcr.io/acme/myapp:1.0.0 .

Very effective for repeat builds across runners.

Pass build secret

Pass a secret into the build without baking it into layers.

bashANYbuildxsecretssecurity
bash
docker buildx build --secret id=npmrc,src=$HOME/.npmrc -t myapp:dev .

A best practice for private package registries.

Forward SSH agent during build

Forward SSH credentials into the build for private Git access.

bashANYbuildxsshsecurity
bash
docker buildx build --ssh default -t myapp:dev .

Useful when a build clones private repositories.

Build from bake definition

Run builds from a Bake definition.

bashANYbuildxbake
bash
docker buildx bake

Useful for orchestrating multiple targets and shared settings.

Inspect remote image platforms

Inspect remote image index details and available platforms.

bashANYbuildximagetoolsmultiarch
bash
docker buildx imagetools inspect ghcr.io/acme/myapp:1.0.0

Excellent for verifying multi-platform publishing.