prakhar1989 / docker-curriculum

:dolphin: A comprehensive tutorial on getting started with Docker!
https://docker-curriculum.com/
MIT License
5.63k stars 2.15k forks source link

static-site:latest fails on MacOS - requested platform does not match detected host platform #349

Open pbadams opened 1 year ago

pbadams commented 1 year ago

Attempting the Docker tutorial on macOS Monterey 12.6.1 (21G217) on an Apple Silicon M1 Pro. Docker for Desktop is installed and functioning.

Running docker run --rm -it prakhar1989/static-site fails with the following:

Unable to find image 'prakhar1989/static-site:latest' locally
latest: Pulling from prakhar1989/static-site
d4bce7fd68df: Pull complete 
a3ed95caeb02: Pull complete 
573113c4751a: Pull complete 
31917632be33: Pull complete 
77e66f18af1c: Pull complete 
df3f108f3ade: Pull complete 
d7a279eb19f5: Pull complete 
e798589c05c5: Pull complete 
78eeaf458ae0: Pull complete 
Digest: sha256:bb6907c8db9ac4c6cadb25162a979e286575cd8b27727c08c7fbaf30988534db
Status: Downloaded newer image for prakhar1989/static-site:latest
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
Nginx is running...
2022/11/29 14:30:50 [emerg] 9#9: io_setup() failed (38: Function not implemented)
NicolasCwy commented 1 year ago

I got around this and cd-ing into Docker-curriculum/static-site and just building the container on my device using docker build -t <username>/<image_name> --platform=linux/arm64/v8 .

Edit: I updated to the latest docker 23.0.5, enabling settings > features for development > "rosetta for x86 emulation"

ashcross commented 5 months ago

to expand on the above for learners like me who had to google it to get it to work on my raspberry pi... cd to wherever you want git clone https://github.com/prakhar1989/docker-curriculum.git cd docker-curriculum/static-site docker build -t prakhar1989/static-site --platform=linux/arm64/v8 . docker run --rm -it prakhar1989/static-site

Above is the process I followed to get it to work, which builds an image suitable for the platform, which you then run.