I would like to run NGINX in Docker and serve some files, but I am not able to do it this way:
docker run --rm --name some-nginx -p 10088:80 -v mydir:/usr/share/nginx/html:ro nginx
I am able to see http://localhost:10088 but if I try to access any file in mydir/
, it fails. For example http://localhost:10088/README.md gives this result:
2020/01/21 07:10:20 [error] 6#6: *1 open() "/usr/share/nginx/html/README.md" failed (2: No such file or directory), client: 172.17.0.1, server: localhost, request: "GET /README.md HTTP/1.1", host: "localhost:10088"
172.17.0.1 - - [21/Jan/2020:07:10:20 +0000] "GET /README.md HTTP/1.1" 404 153 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0" "-"
Any idea how to setup nginx easily?
Note: I don't want to create new image as suggested at https://hub.docker.com/_/nginx, I want to use volume.
Note 2: I've just noticed (after attach to the nginx container):
root@a2813aa84991:/usr/share/nginx/html# ls
50x.html index.html
It seems volume mydir/
is not mounted.