≡ Menu

How to Build an amd64 AND arm64 Docker image on a M1 Mac


  1. Create a new builder instance
    docker buildx create --use
  2. Build for multiple platforms, tag, and push to Dockerhub
    docker buildx build --platform linux/amd64,linux/arm64 --push -t <tag_to_push> .

The backstory

A while ago I was playing around with a nifty Open Source project called speed-camera which uses Python and OpenCV to track the speed of objects.

To make it easier to deploy, I created a docker Image for version 10.22 of the project, pushed it to dockerhub, and submitted a PR to let others benefit from it as well.

Fast forward and the maintainer of speed hub is now @ version 11.22 but my docker image is still sporting 10.22. He asked me to update the image… Sure! No problem!

So I pulled the repo to my machine bumped the version, created/tagged/pushed the new image to dockerhub. A day later, someone mentioned that it was built for arm64 and not amd64. Whoops! I recently got a new M1 Mac sporting that shinny and amazingly performant Apple Silicon and this didn’t cross my mind as this was the first docker image I’d pushed with my new Mac.

So like any normal person, I headed over to Google which led me to a blog post by Jaimyn that gave me the commands needed to build the docker image for multiple platforms, linux/amd64 and linux/arm64 in my case.

Something worth noting, buildx is no longer and “Experimental Feature” so you can drive right into creating the new builder instance with docker buildx create --use

{ 0 comments… add one }

Leave a Comment