docker-buildx(1)
Build images with BuildKit, supporting multiple platforms, caching, and advanced container image creation.
Synopsis
docker buildx [COMMAND]Description
docker buildx is a Docker CLI plugin that extends the standard docker build command with BuildKit backend capabilities. It enables building container images for multiple platforms simultaneously, supports advanced caching strategies, and provides better performance through parallel builds.
BuildKit is a modern container image builder that offers improved build performance, caching, security, and support for advanced features like secrets and SSH forwarding. Buildx manages BuildKit builder instances and makes them accessible through familiar Docker commands.
Common options
| Flag | What it does |
|---|---|
create | Create a new builder instance with a specific driver (docker, docker-container, kubernetes) |
use | Set the current builder instance to use for subsequent builds |
ls | List all available builder instances |
rm | Remove a builder instance |
--platform | Target platforms for multi-arch builds, e.g. linux/amd64,linux/arm64 |
--output | Output destination (docker, oci, image, etc.); use docker to load into Docker daemon |
--cache-to | Export build cache to registry or local directory for reuse |
--cache-from | Import cache from registry or local source to speed up builds |
--secret | Pass secrets during build without including them in image layers |
--ssh | Forward SSH agent to build for private git repository access |
--load | Load built image directly into Docker daemon (single-platform only) |
--push | Push image directly to registry after building |
Examples
Create a new builder instance using the docker-container driver for advanced features
docker buildx create --name mybuilder --driver docker-containerSwitch to the mybuilder instance for subsequent builds
docker buildx use mybuilderBuild image for both AMD64 and ARM64 platforms and push to registry
docker buildx build --platform linux/amd64,linux/arm64 -t myimage:latest --push .Build image and load it directly into the local Docker daemon
docker buildx build -t myimage:latest --load .Build with secret injection and SSH agent forwarding for secure builds
docker buildx build --secret id=mytoken --ssh default .Build with local cache export and import to speed up rebuilds
docker buildx build --cache-to type=local,dest=./buildcache --cache-from type=local,src=./buildcache -t myimage .List all available builder instances and their details
docker buildx lsBuild for ARM64 and output as OCI image tarball instead of pushing to registry
docker buildx build --platform linux/arm64 --output type=oci,dest=./output .