11

I have a Docker image that was built and uploaded to Amazon ECR by a x86 machine.

I'm trying to run this image on an ARM machine; however, I'm getting the following:

$sudo docker run 1b3ed34937e8

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
standard_init_linux.go:228: exec user process caused: exec format error

Do I need to rebuild this image? Is it possible to rebuild with only an image and not a dockerfile?

secam74499
  • 179
  • 1
  • 1
  • 7

3 Answers3

7

You can also use the emulation-layer built into docker:

docker run --platform linux/amd64 {imagename}

Since this is based on emulation it will not be as performant as running the container using the host architecture.

Andreas.Ludwig
  • 372
  • 3
  • 6
  • How shall I run a docker-compose which has many x86 docker containers. I am trying to run that on ARM architecture. – Proton Mar 04 '23 at 06:44
  • 2
    Apparently you can use the environment variable `DOCKER_DEFAULT_PLATFORM` . Try setting that environment variable in your shell session before starting the containers via your compose file: ```export DOCKER_DEFAULT_PLATFORM=linux/amd64``` For further information have a look at this SO-issue: https://stackoverflow.com/questions/65612411/forcing-docker-to-use-linux-amd64-platform-by-default-on-macos – Andreas.Ludwig Mar 06 '23 at 07:55
4

You are trying to build x86 Docker images on a different architecture (ARM).

Rebuild the images on the Mac, or if you are still building the image on X86 you can set the target platform

docker buildx build --platform darwin/amd64 -t app .
Beppe C
  • 11,256
  • 2
  • 19
  • 41
0

For future searchs, you can to install qemu emulation:

apt-get install qemu binfmt-support qemu-user-static

ref.: https://www.stereolabs.com/docs/docker/building-arm-container-on-x86/

rafaelnaskar
  • 619
  • 6
  • 11