How to Serve HTML Files from a Nginx Server Using Docker



I have a Nginx container running in docker. It's configured to listen to port http://localhost:80 . When I type the url to my browser I get the following...

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to Commercial support is available at

Thank you for using nginx.

Cont'd of Problem

I want nginx to serve my html files from my public directory. Please take a look at my project images...

Project Images:

Project directory

Nginx Container Running

What I have done

  1. Ran the following docker command from my public directory...

    • $ docker run -d --name chat-web -v $PWD:/var/www -p 80:80 nginx
  2. Search for the location of nginx server from /usr/local/bin , /usr/private/var so that I can modify nginx.conf as described in the following post NGinx Default public www location?. I was unable to find the location of the nginx server.

Thanks in advance for taking the time to answer my question. I really appreciate you.

TJ Biddle

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

Collected from the Internet

Please contact javae[email protected] to delete if infringement.

edited at


Login to comment


TOP Ranking