liveBook · Manning

Buildx

As explained in Learn Docker in a Month of Lunches, Second Edition

Buildx is Docker's extended build client for building container images with advanced features including multi-platform builds.

Buildx extends Docker’s build commands with an optimized build engine while keeping Dockerfiles as input and images as output. It acts as a replacement for docker image build and supports distributed, multi-platform builds across Docker Engines. section 12.4

A practical Buildx workflow uses:

  • Docker contexts to describe connections to Docker Engines. section 12.4
  • Builder nodes, each assigned a target platform such as linux/amd64 or linux/arm64. section 12.4
  • A single build command that builds and pushes a multi-platform image. section 12.4

Create a small multi-platform build farm

Duplicate the current Docker context, create a builder with amd64 and arm64 nodes, then run docker buildx build with --platform linux/arm64,linux/amd64 and --push. Two contexts can point to one local engine for practice; real farms use networked engines secured with SSH or TLS. section 12.4

# build and push the hello app for all the builder's platforms:
docker buildx build --builder ch12-builder `
 --platform linux/arm64,linux/amd64 `
 -t "$dockerId/ch12-hello-x:2e" `
 --push ./hello

Inspect the complete build-and-push command for the example application. section 12.4

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Walks through contexts, builder nodes, and a distributed build, but stops short of multiple Dockerfiles and robust Windows support.
Examples
Uses a duplicated local context, two platform-specific builder nodes, and a pushed hello application image.
What it assumes
Assumes Docker contexts, Docker Engines, Dockerfiles, and image publishing; teaches the builder setup workflow incrementally.
What you can do after
Operate Buildx to create builders and push one image supporting multiple Linux CPU platforms.
How it connects
Connects Dockerfiles, Docker images, Docker contexts, Docker Engines, builders, and multi-platform manifests.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.