| name | docker-multi-platform |
|---|---|
| description | Multi-architecture builds, buildx builder configuration, manifest lists, platform targeting, and cross-compilation patterns. |
| standards-version | 1.6.3 |
Use this skill when:
- Building Docker images for multiple CPU architectures (amd64, arm64, armv7, s390x)
- Configuring buildx builders for multi-platform output
- Creating or managing manifest lists for multi-arch image distribution
- Setting up CI/CD pipelines that produce multi-platform images
- Troubleshooting cross-compilation or platform-specific build failures
- Optimizing build cache for multi-platform workflows
- Target platforms (e.g. linux/amd64, linux/arm64)
- Dockerfile path and build context
- Registry destination (if pushing multi-platform images)
- Builder driver preference (docker-container, kubernetes, remote)
- Assess platform requirements - determine which architectures the image must support
- Configure builder - create or select a buildx builder with the right driver
- Prepare Dockerfile - ensure platform-agnostic instructions or use
TARGETPLATFORM/TARGETARCHARGs - Build - run
docker buildx build --platformwith appropriate cache and output options - Verify - inspect the resulting manifest list to confirm all platforms are present
- Distribute - push to registry or use
docker buildx imagetoolsto combine images
docker buildx build --platform linux/amd64,linux/arm64- the core multi-platform build commanddocker buildx create --driver docker-container- create a builder capable of multi-platformdocker buildx ls- verify available builders and their platform supportdocker manifest create/annotate/push- manual manifest list managementTARGETPLATFORM,TARGETARCH,TARGETOS,TARGETVARIANT- automatic ARGs available in Dockerfiles during cross-builds
User: I need my Go API image to run on both amd64 and arm64. How do I set that up?
Assistant: Here's the approach:
- Create a buildx builder with docker-container driver (supports multi-platform):
docker buildx create --name multiarch --driver docker-container --use
- Use a multi-stage Dockerfile with cross-compilation:
FROM --platform=$BUILDPLATFORM golang:1.22-alpine AS builder
ARG TARGETARCH
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOARCH=$TARGETARCH go build -o /api .
FROM alpine:3.20
COPY --from=builder /api /api
ENTRYPOINT ["/api"]- Build and push for both platforms:
docker buildx build --platform linux/amd64,linux/arm64 \
--tag myregistry/api:latest --push .
- Verify the manifest:
docker manifest inspect myregistry/api:latest
This skill leverages the following MCP tools:
docker_buildxBuild- run multi-platform builds with cache and provenance optionsdocker_buildxLs- list builders and check platform supportdocker_buildxCreate- create a builder with the right driver for multi-platformdocker_buildxRm- clean up builders no longer neededdocker_buildxInspect- check builder status and supported platformsdocker_buildxUse- switch between buildersdocker_buildxImagetools- inspect and create manifest lists via buildxdocker_builderPrune- clean build cachedocker_manifestCreate- create manifest lists manuallydocker_manifestInspect- verify manifest list contents and platformsdocker_manifestAnnotate- set platform metadata on manifest entriesdocker_manifestPush- push manifest lists to registriesdocker_manifestRm- remove local manifest listsdocker_build- single-platform builds (for comparison or fallback)
- Using
docker buildinstead ofdocker buildx build- the regulardocker buildcannot produce multi-platform images. You need buildx with a docker-container or remote driver. - Default builder lacks multi-platform - the default
dockerdriver only builds for the host architecture. Create a builder with--driver docker-container. - Architecture-specific commands in Dockerfile - hardcoded
wgetURLs withamd64in the path, or architecture-specific binaries, break on other platforms. UseTARGETARCHARG. - Missing QEMU for emulated builds - cross-architecture builds need QEMU registered. Run
docker run --privileged --rm tonistiigi/binfmt --install allfirst. --pushvs--load- multi-platform builds cannot use--load(which loads into local Docker). Use--pushto a registry, or build one platform at a time with--load.- No cache configuration - multi-platform builds are slow. Use
--cache-fromand--cache-towith registry or local cache backends. - Forgetting
--platformin FROM - in multi-stage builds, the build stage should useFROM --platform=$BUILDPLATFORMto run on the host architecture for speed, while the runtime stage inherits the target platform.
- dockerfile-best-practices - general Dockerfile optimization
- image-optimization - reducing image sizes (applies per-platform)
- docker-registry - pushing multi-arch images to registries
- docker-ci-cd - CI/CD pipelines with multi-platform builds