How to enable multi-platform Docker builds on Ubuntu 22.04

Docker’s official documentation on how to enable multi-platform Docker builds is a bit intimidating, suggesting you to run the Docker image tonistiigi/binfmt in privileged mode on your machine. I searched for alternatives on Ubuntu, and found this very detailed description. However, with recent versions of Ubuntu and Docker, it is now much easier than that:

  1. Install QEMU’s static user mode emulation binaries:
    sudo apt install qemu-user-static
  2. Install Docker Engine with Buildx support according instructions here (do not install docker-ce or from Ubuntu’s standard repository).
  3. Create a Docker Buildx builder:
    docker buildx create --name multiplatform --bootstrap --use
  4. Verify it:
    docker buildx inspect

Then you can do multi-platform Docker builds like this:
docker buildx build --platform linux/amd64,linux/arm64 .

This entry was posted in Docker, Linux, Ubuntu. Bookmark the permalink.