How to build Linux Docker images on a Mac

Posted by in DevOps, last updated on 05 March, 2025

The command

This is a short snippet I use to build and push Linux Docker images on my M1 Macbook Air.

docker buildx build --platform linux/amd64 \
  -t <namespace>/<repository>:<tag> \
  -t <namespace>/<repository>:latest . \
  --push

I’m tagging the image twice, once with a unique tag and once with latest. This is so that I can use the latest tag in my CI/CD pipeline but don’t lose the image history in my registry in case I need to roll back.

For example to build and push an image to Docker Hub if my username was mrdocker and my repo name is awesome_app and the tag the commit hash:

docker buildx build --platform linux/amd64 \
  -t mrdocker/awesome_app:123abc45de \
  -t mrdocker/awesome_app:latest . \
  --push

Note that if don’t want to push and just need the image locally you can replace the --push with --load.

Happy building!

Click here to get $200 free credits with DigitalOcean.

Sign up and get a $200, 60-day credit to try any DigitalOcean product including servers, managed DBs, kubernetes and their app plaftorm.

I don't receive any money as an affiliate however if you end up spending $25 I will receive a $25 credit as well which helps with my hosting and testing more tech :)


Daniel Wachtel

Written by Daniel Wachtel

Daniel is a Full Stack Engineer who outside work hours is usually found working on side projects or blogging about the Software Engineering world.