How to set Architecture for docker build to arm64? How to set Architecture for docker build to arm64? docker docker

How to set Architecture for docker build to arm64?


https://docs.docker.com/desktop/multi-arch/

# Shows builders installeddocker buildx ls# Use builder that supports platformdocker buildx use defaultdocker buildx build --platform linux/arm64 -t <image_name>:<image_tag> --push .


I was able to solve the problem, not exactly as I wanted, but close enough.

  1. Have an amd64 Linux machine with docker

  2. Setup qemu user static for arm support https://hub.docker.com/r/multiarch/qemu-user-static/

  3. In your docker file use base image with support for arm. E.g. ubuntu

  4. Build your image with command similar to the following:

    docker build --platform arm --pull -t your_tag .

This command will force docker to pull arm version of the base image and will also set arm architecture to your result image. But be careful, if you use tags with multiple architectures, the command above will set the tag to arm version. So to run the native amd64 version you will need to pull the tag again without --platform arg.