urre / wordpress-nginx-docker-compose

Run WordPress with nginx using Docker Compose.
783 stars 309 forks source link

The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) #107

Open kaelansmith opened 1 year ago

kaelansmith commented 1 year ago

When running docker-compose up, I get this warning in my terminal: "wordpress The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested" -- screenshot: image

I see you mentioned something similar in this other issue:

Hey, yea I have the same issues actually, also on M1 now. It's the Docker images not tuned for ARM. Will look into it

Originally posted by @urre in https://github.com/urre/wordpress-nginx-docker-compose/issues/105#issuecomment-1375217348

But in my case, it seems like instead of the Docker images not being tuned for ARM, they aren't tuned for AMD. I know nothing about this stuff, but Docker Desktop also highlights this issue and says "ARM64: Image may have poor performance, or fail, if run via emulation" -- and my local WordPress backend is quite slow, so seems like this could be the cause. Is this possible to fix within the existing Docker image, or will it require using a different image?

urre commented 1 year ago

Docker should pick automatically select the image from the base image I use that matches your OS and architecture. I'm on a M1 Mac now and if I do docker image inspect wordpress-nginx-docker-compose_wordpres I can see it is correct "Architecture": "arm64"

You can specify using --platform also

kaelansmith commented 1 year ago

@urre Thanks for the hint. I got it to use amd64 by doing:

  1. Run docker pull --platform linux/amd64 urre/wordpress-nginx-docker-compose-image
  2. Edit Dockerfile's "FROM" clause to FROM --platform=amd64 urre/wordpress-nginx-docker-compose-image:latest --> I had to change to "latest" (for an unknown reason) because it continued to use arm64 when the image version "1.4.0" was specified
  3. Run docker compose up -d --force-recreate --build

After doing this, running docker image inspect <IMAGE_NAME> confirmed that it switched to using amd64 and the arm64 warning messages in my terminal and in Docker Desktop disappeared. HOWEVER, doing this also switched the PHP version to 7.4.10 (instead of 8.1.15) and WordPress version to 5.5.1 (instead of 6.0) -- and I end up with a composer error because I have dependencies that require PHP 8.0+. I don't know enough about Docker to know why this happens -- do you have any clue how to fix this so that I can use amd64 with PHP 8.0+ and WordPress 6.0+?

kaelansmith commented 1 year ago

To add to my last message --> I'm pretty sure that when I specify linux/amd64, it reverts to using an older version of the image, specifically the version from your September 21, 2020 commit which at that time was using PHP 7.4 and WP 5.5.1: https://github.com/urre/wordpress-nginx-docker-compose-image/commit/2b7409f3d301c109a3eb7ccb8bf0083b89edafd1

Possibly the next commit after that one, Use php 8.1.3 and imagic 3.7.9 , added something that isn't compatible with amd64? So when specifying amd64 it reverts to the most recent compatible image (just guessing)?