19

Problem

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 nginx.org. Commercial support is available at nginx.com.

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.

Uchenna
  • 321
  • 1
  • 4
  • 10

2 Answers2

49

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
TJ Biddle
  • 6,024
  • 6
  • 40
  • 47
  • @Uchenna - Great! Could you please mark the answer as accepted and vote on it to help others? – TJ Biddle Dec 01 '17 at 02:25
  • 4
    I tried to vote, Since I am new in stack exchange I have to get more than 15 reputation to display the post score. Once I get the reputation score, I will vote your answer up. Thank you :) – Uchenna Dec 01 '17 at 13:58
  • This must be the quickest way to deploy a server. THanks! – Gogol Jun 20 '21 at 09:35
0

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