I've got a mix of architectures in my basement cluster - some Odroid HC2s that are arm7, some Raspberry Pi 4s that are arm64, and am soon going to add an Intel node as well. It's more hassle than it's worth to have to specify different images for the different architectures. I already build my own copies of images, so I decided to start building all my images as multiarchitecture images.
This turned out to be a lot easier than I was expecting - recent stable builds (18.104.22.168 (33772) or higher) of Docker Desktop can build for other architectures by running virtual machines in QEMU, so I can do the whole build on my MacBook Pro instead of baking each architecture separately and stitching them together with a manifest file.
- Install the latest Docker Desktop for macOS
- Enable experimental mode either by setting
DOCKER_CLI_EXPERIMENTAL=enabledin your environment or by adding
"experimental" : "enabled"to
docker buildx lsto see the current builders
docker buildx create --name multiarch
docker buildx use multiarch
docker buildx inspect --bootstrap
Now you're ready to build. Go into one of your docker projects, then do
docker buildx --platform linux/amd64,linux/arm64,linux/arm/v7 -t username/demo --push .
If you're not ready to push your image to docker hub, do
--load instead of
--push to have it build the image and copy it out of the buildx system and into your local docker.