DEV Community

Cover image for Understanding Docker Buildx & Builder: Modern Docker Builds with BuildKit
Athreya aka Maneshwar
Athreya aka Maneshwar

Posted on

Understanding Docker Buildx & Builder: Modern Docker Builds with BuildKit

Hi there! I'm Maneshwar. Right now, I’m building LiveAPI, a first-of-its-kind tool that helps you automatically index API endpoints across all your repositories. LiveAPI makes it easier to discover, understand, and interact with APIs in large infrastructures.


With modern Docker tooling, docker buildx is the preferred way to unlock advanced build features powered by BuildKit.

If you're still relying on classic docker build, you're missing out on faster builds, better caching, and powerful features like multi-arch images and inline secrets.

Let's break it down.

What is docker buildx?

docker buildx is a CLI plugin that extends the docker build command with BuildKit, a modern builder engine developed by Docker. It gives you access to:

  • Faster builds
  • Layer caching
  • Parallelization
  • Multi-platform support (e.g. linux/arm64, linux/amd64)
  • Better control over builder instances
  • Disk usage management

Getting Started

First, make sure you're using Docker with BuildKit enabled.

Add this to your shell config or export directly:

export DOCKER_BUILDKIT=1
export BUILDX_EXPERIMENTAL=1
Enter fullscreen mode Exit fullscreen mode

Common docker buildx Commands

Here are the core commands you'll use:

build

The bread and butter. Like docker build, but better.

docker buildx build --platform linux/amd64,linux/arm64 -t myimage:latest .
Enter fullscreen mode Exit fullscreen mode

Use --push to push directly to registry after build:

docker buildx build --platform linux/amd64,linux/arm64 -t user/myimage:latest --push .
Enter fullscreen mode Exit fullscreen mode

bake

Declarative builds via docker-bake.hcl or docker-compose.yml.

docker buildx bake
Enter fullscreen mode Exit fullscreen mode

Great for managing multiple targets/images in one shot.

Builder Instances

create

Set up an isolated builder environment:

docker buildx create --name mybuilder --use
Enter fullscreen mode Exit fullscreen mode

This creates and uses mybuilder. You can now build multi-platform images and share cache state.

inspect

Check details:

docker buildx inspect --bootstrap
Enter fullscreen mode Exit fullscreen mode

ls

List all your builders:

docker buildx ls
Enter fullscreen mode Exit fullscreen mode

prune

Free up disk space:

docker buildx prune
Enter fullscreen mode Exit fullscreen mode

Registry Tools

docker buildx imagetools helps inspect and work with multi-arch images stored in a registry:

docker buildx imagetools inspect user/myimage:latest
Enter fullscreen mode Exit fullscreen mode

♂️ Debug & Experimental Mode

Enable debug logging:

docker buildx --debug build ...
Enter fullscreen mode Exit fullscreen mode

To unlock hidden experimental features:

export BUILDX_EXPERIMENTAL=1
Enter fullscreen mode Exit fullscreen mode

Other Useful Commands

Command Description
du Check build cache disk usage
rm Remove builder instances
stop Stop a running builder
version Print version info of Buildx
history Work with previous build records

Summary

If you're building Docker images in 2025 and not using buildx, you're leaving performance and control on the table.

Key benefits:

  • Multi-arch builds
  • Smart caching
  • Cleaner build management
  • Better registry tooling

Quick Setup for Daily Use

docker buildx create --use --name devbuilder
docker buildx build --platform linux/amd64,linux/arm64 -t youruser/yourapp:tag --push .
Enter fullscreen mode Exit fullscreen mode

Done. You’ve now entered the world of modern Docker builds. 🐳


LiveAPI helps you get all your backend APIs documented in a few minutes.

With LiveAPI, you can generate interactive API docs that allow users to search and execute endpoints directly from the browser.

LiveAPI Demo

If you're tired of updating Swagger manually or syncing Postman collections, give it a shot.

Top comments (0)