Docker get-started: WARNING: The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64)
Asked Answered
D

2

24

I'm starting the "get-started" guide from official Docker website. At the Part 4 "Share the application", I'm facing this error message when I try to run my image on the docker hub from play-with-docker.com.

WARNING: The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested

I built the image from my apple M1 laptop:

FROM node:12-alpine
# Adding build tools to make yarn install work on Apple silicon / arm64 machines
RUN apk add --no-cache python2 g++ make
WORKDIR /app
COPY . .
RUN yarn install --producti
CMD ["node", "src/index.js"]
Dermatology answered 5/2, 2022 at 18:1 Comment(1)
I'm doing the same tutorial on arm osx. I get the same error. Pity the play with docker website does not have any method to host arm images.Inarticulate
U
28

If you want to run the image on a linux/amd64 platform, you need to build it for that platform. You can do that with docker buildx like this and specify both your platforms

docker buildx build --platform linux/amd64,linux/arm64 -t <tag> .
Uppity answered 5/2, 2022 at 19:5 Comment(6)
What are we using that with the run command?Wendiewendin
Note that if you get an error like "WARNING: No output specified for docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load" when running this command, you can solve that by immediately pushing the image to Dockerhub: "docker buildx build --push --platform linux/amd64,linux/arm64 -t <tag> ."Logography
I got the following error: ERROR: multiple platforms feature is currently not supported for docker driver. Please switch to a different driver (eg. "docker buildx create --use"). How can I fix it?Reticent
@wang issue the command suggested. docker buildx create --use. Afterwards, use the command provided in my answer.Inarticulate
After that, the buildx build command fails for me with "failed to solve: failed to read dockerfile: open /tmp/buildkit-mount544735555/Dockerfile: no such file or directory".Countersink
Some explanation in here: devblogs.microsoft.com/azure-sql/…Abruption
I
2

I had the same error as srevinu as I was also using the tutorial which points to using the docker playground.

This sequence will build and push to docker hub so that it can be run on docker playground.

  1. On your osx arm based computer docker buildx build --platform linux/amd64,linux/arm64 -t <YOUR_DOCKERHUB_ID/getting-started --push .

(If it gives an error and suggestion about issuing a docker buildx create --use, enter the command verbatim.)

After this command in tags pane on docker hub, you should see two platforms listed for the image. One image for linux/amd64 and one for linux/arm64.

enter image description here

  1. On docker playground in the instance, docker run -dp 3000:3000 --platform linux/amd64 johndavis940/getting-started

The image will run and the port icon will be functional.

Inarticulate answered 23/1, 2023 at 19:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.