Reputation: 2565
I have an m1 mac and I am trying to run a amd64 based docker image on my arm64 based host platform. However, when I try to do so (with docker run) I get the following error:
WARNING: The requested image's platform (linux/amd64) does not
match the detected host platform (linux/arm64/v8)
and no specific platform was requested.
When I try adding the tag --platform linux/amd64
the error message doesn't appear, but I can't seem to go into the relevant shell and docker ps -a
shows that the container is immediately exited upon starting. Would anyone know how I can run this exact image on my machine given the circumstances/how to make the --platform
tag work?
Upvotes: 120
Views: 172939
Reputation: 310
Ensure that --platform linux/amd64
is immediately after run
, otherwise it may not work. Correct:
docker run --platform linux/amd64 image_name
Upvotes: 24
Reputation: 4346
To address the problem of your container immediately exiting after starting, try using the entrypoint flag to overwrite the container's entry point. It would look something like this:
docker run -it --entrypoint=/bin/bash image_name
Credit goes to this other SO answer that helped me solve a similar issue on my own container.
Upvotes: 6
Reputation: 4977
Using --platform
is correct. On my M1 Mac I'm able to run both arm64 and amd64 versions of the Ubuntu image from Docker Hub. The machine hardware name provided by uname proves it.
# docker run --rm -ti --platform linux/arm/v7 ubuntu:latest uname -m
armv7l
# docker run --rm -ti --platform linux/amd64 ubuntu:latest uname -m
x86_64
Running amd64 images is enabled by Rosetta2 emulation, as indicated here.
Not all images are available for ARM64 architecture. You can add
--platform linux/amd64
to run an Intel image under emulation.
If the container is exiting immediately, that's a problem with the specific container you're using.
Upvotes: 166