DEV Community

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

Posted on • Edited on

Understanding Docker Buildx & Builder: Modern Docker Builds with BuildKit

Hello, I'm Maneshwar. I'm building git-lrc, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. Star Us to help devs discover the project. Do give it a try and share your feedback for improving the product.

With modern Docker tooling, docker buildxis 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. 🐳


git-lrc
*AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.

git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.*

Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.

⭐ Star it on GitHub:

GitHub logo HexmosTech / git-lrc

Free, Unlimited AI Code Reviews That Run on Commit




AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.

git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.

See It In Action

See git-lrc catch serious security issues such as leaked credentials, expensive cloud operations, and sensitive material in log statements

git-lrc-intro-60s.mp4

Why

  • 🤖 AI agents silently break things. Code removed. Logic changed. Edge cases gone. You won't notice until production.
  • 🔍 Catch it before it ships. AI-powered inline comments show you exactly what changed and what looks wrong.
  • 🔁 Build a

Top comments (0)