Docker buildx

The high-performance backend for Docker builds

November 01, 2025

Building Docker images has evolved a lot over the years. If you’re still using docker build, it’s time to meet its modern, high-performance replacement, Docker buildx, powered by BuildKit.

What is docker buildx

Docker buildx is an extended build command that uses Docker’s BuildKit engine. It replaces the old docker build command with a more powerful, modern, and flexible system for building Docker images.

How to enable Docker buildx

Docker buildx is included and enabled by default in Docker 23.0 and later. For older versions (19.03–22.x), you may need to create and activate a builder instance manually. Here’s how to get started:

# 1. Create a new builder instance
docker buildx create --name mybuilder --use

# 2. Inspect and bootstrap the builder to verify it’s ready
docker buildx inspect --bootstrap

# 3. Confirm buildx is active and list all builders
docker buildx ls

With the builder active, you’re ready to take advantage of BuildKit’s advanced features and faster, more efficient builds.

What buildx can do

1. Multi-platform builds

You can build images for multiple architectures like linux/amd64 and linux/arm64, from any machine.

docker buildx build 
  --platform linux/amd64,linux/arm64 
  --push
  -t myregistry/myapp:latest .

This single command builds both versions and pushes them to your Docker registry, no need for separate hardware or emulators. For cross-architecture builds, buildx relies on QEMU emulation, which Docker Desktop and BuildKit automatically configure.

2. Remote builders

Docker buildx isn’t limited to your local machine, you can connect it to remote Docker hosts and build images on more powerful servers, or even other architectures.

Run the following commands to create a builder that runs on a remote Docker host over SSH.

docker buildx create --name remote-builder --driver docker-container ssh://[email protected] --use

docker buildx inspect --bootstrap

With the remote builder active, any docker buildx build command will run on that remote machine. Your local machine sends the build context and instructions, while the remote server performs the build. This lets you offload heavy build workloads without needing additional local resources.

3. Advanced caching

Buildx can use remote caches to speed up builds dramatically.

docker buildx build
  --cache-from=type=registry,ref=myregistry/myapp:cache
  --cache-to=type=registry,ref=myregistry/myapp:cache,mode=max
  -t myregistry/myapp:latest .

4. Inline and local exports

You can export built images as .tar files or directly load them into the Docker daemon:

docker buildx build 
  --output type=local,dest=./output .

If you want to load the image directly into your local Docker engine, you can use the --load flag instead:

5. Bake

Think of docker buildx bake as Docker Compose, but for building images. It makes managing multi-target builds simple, repeatable, and scalable. Here are a few reasons it’s great:

  • - You can define multiple build targets in one file docker-bake.hcl
  • - You can define shared build arguments, contexts, and variables.
  • - You can run all builds at once and automatically push the artifacts

Here’s what that looks like in action:

group "default" {
  targets = ["base", "devops"]
}

variable "REGISTRY" {
  default = "test.dev"
}

variable "IMAGE" {
  default = "${REGISTRY}/dev"
}

target "base" {
    dockerfile = "Dockerfile"
    tags = ["${IMAGE}"]
    cache-from = ["type=registry,ref=${IMAGE}:cache"]
    cache-to = ["type=registry,ref=${IMAGE}:cache,mode=max"]
}

target "devops" {
    dockerfile = "devops.Dockerfile"
    contexts = {
        base = "target:base"
    }
    tags = ["${IMAGE}:devops"]
    cache-from = ["type=registry,ref=${IMAGE}:cache-devops"]
    cache-to = ["type=registry,ref=${IMAGE}:cache-devops,mode=max"]
}

In this Bake file, we define two targets, base and devops, each with its own Dockerfile. The devops image depends on the base image, which it references through a context. Each target also defines its own tags and caching strategy, making builds faster and more reliable.

Final Thoughts

Docker buildx takes image building to the next level, faster, smarter, and build for modern workflows. If you haven’t switched yet, now’s the time to make buildx your default for efficient, reliable, and scalable Docker builds.

Share

Comments (0)