2

Let's say I have an app foo built for many different arches (e.g, foo-arm64, foo-amd64, etc). I would like to make very small Docker images like so:

FROM scratch

ARG ARCH
ADD foo-$ARCH /bin/foo

ENTRYPOINT [ "/bin/foo" ]

However, when I build an image:

docker build -t foo:arm64 --platform linux/arm64 --build-arg ARCH=arm64 .

the architecture isn't correct:

docker inspect foo:arm64 | grep Arch
        "Architecture": "amd64",              # should be arm64??

The image arch seems to always come from the host. How can I build a Docker image with the right architecture when that differs from the host? How do the official Docker images do this?

paleozogt
  • 6,393
  • 11
  • 51
  • 94

1 Answers1

2

Use docker buildx command instead of docker build -t command. Docker build only create docker image with respective platform.

For more information refer documentation : https://www.docker.com/blog/multi-arch-images/

snehal
  • 460
  • 3
  • 8