Dockerized nginx does not serve HTML page

Mac OS is here by running Docker Version 17.12.0-ce-mac49. I have the following super simple Dockerfile :

 FROM nginx COPY index.html /usr/share/nginx/html 

I am creating a Docker image:

 docker build -t mydocbox . 

So far so good, no mistakes. Then I create a container from this image:

 docker run -it -p 8080:8080 -d --name mydocbox mydocbox 

And I see that it works (I confirmed its launch by issuing docker ps , as well as SSHing in the field via docker exec -it <containerId> bash and confirming /usr/share/nginx/html/index.html )!

When I open the browser and go to http://localhost:8080 , I get a blank / blank / screen not showing anything here, and not the expected index.html page.

I see no errors anywhere, and nothing to indicate that the configuration is bad or that firewalls are causing problems. Any ideas on what might be the problem and how can I troubleshoot?

+5
source share
1 answer

See if you can follow this example :

 FROM nginx:alpine COPY default.conf /etc/nginx/conf.d/default.conf COPY index.html /usr/share/nginx/html/index.html 

It uses the default.conf file , which defines the index.html used

 location / { root /usr/share/nginx/html; index index.html index.htm; } 

Change the listening port in default.conf from 80 to 8080 and EXPOSURE.
Or just docker run with -p 8080:80 (hostPort: containerPort).

+4
source

Source: https://habr.com/ru/post/1275207/


All Articles