How to Serve HTML Files from a Nginx Server Using Docker
The default directory that static assets are served out of is /usr/share/nginx/html
, not /var/www
in the Official NGINX Docker image.
With that said, you're also mapping your entire root directory and not the /public/
folder where your folder contents live - unless of course you're running this from that directory on a pre-build image.
You'll probably want something like:
➜ docker run -p 80:80 -v $(pwd):/usr/share/nginx/html nginx
Mee too got the same error. I was doing on aws cloud. I added ports, servers, but didn't worked. So I just installed nginx in another instance, copied default nginx.conf file, pasted into nginx container volume file.Stop container, start it again. Try it. It should run.
Try with public ip addr.
Volume will be available @ /var/lib/docker/volumes//_data/nginx.conf