Docker · Containers in practice
How do you build images for multiple CPU architectures?
Short answer
Use docker buildx with --platform and push a manifest list. Native builders are fast; QEMU emulation works but is slow and can fail on architecture-specific code.
A multi-platform build produces one tag backed by a manifest list that points to per-architecture images. The client pulls the variant matching its platform. Base images must also publish the target architecture.
docker buildx create --name multi --driver docker-container --use
docker buildx build --platform linux/amd64,linux/arm64 \
--push -t registry.example.com/api:1.0.0 .
docker buildx imagetools inspect registry.example.com/api:1.0.0Practical constraints
- QEMU emulation is convenient but much slower and can expose timing or instruction issues
- Native arm64 builders are the reliable path for heavy builds
- Some dependencies need cross-compilation flags or a target-specific toolchain
- CGO and native modules may need architecture-specific build stages
- Base image tags must support every requested platform
Test the arm64 image on arm64 hardware before release. A successful cross-build does not prove the binary runs correctly, especially for code with assembly, JIT or native libraries.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1What is a manifest list?
- 2Why is QEMU emulation slow?
- 3How do you handle a dependency that does not cross-compile?
- 4How do you verify the arm64 image actually works?
Say it in the interview
I use buildx with --platform and push a manifest list so clients pull the matching architecture. For heavy builds I prefer native builders, because QEMU emulation is slow and can hide architecture-specific failures. I also test the arm64 image on real arm64 hardware, since a successful cross-build does not prove the binary runs correctly.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Docker mock interview and get scored feedback on depth, clarity and confidence.