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
Show Buildx version
docker buildx version

# Show Buildx version and component details.

List builders
docker buildx ls

# List available builders and supported platforms.

Create a builder
docker buildx create --name multiarch --use

# Create and switch to a new builder instance.

Inspect current builder
docker buildx inspect --bootstrap

# Inspect and bootstrap a builder.

Use a builder
docker buildx use multiarch

# Switch to a named builder.

Remove a builder
docker buildx rm multiarch

# Delete a builder instance.

## Buildx Build Workflows
Build with Buildx
docker buildx build -t ghcr.io/acme/myapp:dev .

# Build using Buildx and BuildKit.

Build and load into local daemon
docker buildx build --load -t myapp:dev .

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

Build and push directly
docker buildx build --push -t ghcr.io/acme/myapp:1.0.0 .

# Build and push the image directly to a registry.

Build multi-platform image
docker buildx build --platform linux/amd64,linux/arm64 --push -t ghcr.io/acme/myapp:1.0.0 .

# Build and publish a multi-platform image.

Build target stage with Buildx
docker buildx build --target build --load -t myapp:build .

# Build a specific stage using Buildx.

Use registry cache
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 .

# Use a remote registry cache for faster CI builds.

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

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

Forward SSH agent during build
docker buildx build --ssh default -t myapp:dev .

# Forward SSH credentials into the build for private Git access.

Build from bake definition
docker buildx bake

# Run builds from a Bake definition.

Inspect remote image platforms
docker buildx imagetools inspect ghcr.io/acme/myapp:1.0.0

# Inspect remote image index details and available platforms.