Mac OS here, 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 create my Docker image:
docker build -t mydocbox .
So far so good, no errors. I then create a container from that image:
docker run -it -p 8080:8080 -d --name mydocbox mydocbox
And I see it running (I have confirmed its running by issuing docker ps
as well as SSHing into the box via docker exec -it <containerId> bash
and confirming /usr/share/nginx/html/index.html
exists)!
When I open a browser and go to http://localhost:8080
, I get an empty/blank/nothing-to-see-here screen, not my expected index.html
page.
I don't see any errors anywhere and nothing to indicate configuration is bad or that firewalls are causing issues. Any ideas as to what the problem could be or how I could troubleshoot?
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 a default.conf file which does specify the index.html used
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
Change in the default.conf
the listening port from 80 to 8080, and EXPOSE it.
Or simply docker run
with -p 8080:80
(hostPort:containerPort).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With