17

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"]
Srevinu
  • 215
  • 1
  • 2
  • 7
  • 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. – netskink Jan 23 '23 at 19:23

2 Answers2

23

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> .
Dan Lowe
  • 51,713
  • 20
  • 123
  • 112
Hans Kilian
  • 18,948
  • 1
  • 26
  • 35
  • 1
    What are we using that with the run command? – withoutOne Mar 18 '22 at 15:42
  • 1
    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 ." – awwsmm Jul 22 '22 at 13:49
  • 1
    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? – Wang Jan 20 '23 at 12:57
  • 1
    @wang issue the command suggested. `docker buildx create --use`. Afterwards, use the command provided in my answer. – netskink Jan 23 '23 at 20:00
  • 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". – And Finally Feb 13 '23 at 12:49
  • Some explanation in here: https://devblogs.microsoft.com/azure-sql/development-with-sql-in-containers-on-macos/ – Campinho Aug 02 '23 at 04:22
1

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.

netskink
  • 4,033
  • 2
  • 34
  • 46