0

This builds and runs without apparent error:

root@mordor:/home/nicholas/docker/nginx# 
root@mordor:/home/nicholas/docker/nginx# docker exec -ti some-nginx bash
root@2c912aa5ce5c:/# 
root@2c912aa5ce5c:/# ls /usr/share/nginx/html/
50x.html  index.html
root@2c912aa5ce5c:/# 
root@2c912aa5ce5c:/# cat /usr/share/nginx/html/50x.html 
<!DOCTYPE html>
<html>
<head>
<title>Error</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>An error occurred.</h1>
<p>Sorry, the page you are looking for is currently unavailable.<br/>
Please try again later.</p>
<p>If you are the system administrator of this resource then you should check
the error log for details.</p>
<p><em>Faithfully yours, nginx.</em></p>
</body>
</html>
root@2c912aa5ce5c:/# 
root@2c912aa5ce5c:/# cat /usr/share/nginx/html/index.html 



hello world

how do I put this file in a diff dir?


root@2c912aa5ce5c:/# 
root@2c912aa5ce5c:/# exit
exit
root@mordor:/home/nicholas/docker/nginx# 
root@mordor:/home/nicholas/docker/nginx# docker container ls
CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS              PORTS                  NAMES
2c912aa5ce5c        some-content-nginx   "/docker-entrypoint.…"   5 minutes ago       Up 5 minutes        0.0.0.0:8080->80/tcp   some-nginx
root@mordor:/home/nicholas/docker/nginx# 
root@mordor:/home/nicholas/docker/nginx# ls
dockerfile  index.html
root@mordor:/home/nicholas/docker/nginx# 
root@mordor:/home/nicholas/docker/nginx# cat dockerfile 
FROM nginx
COPY index.html /usr/share/nginx/html
root@mordor:/home/nicholas/docker/nginx# 
root@mordor:/home/nicholas/docker/nginx# cat index.html 



hello world

how do I put this file in a diff dir?


root@mordor:/home/nicholas/docker/nginx# 

Yet, there's no output when browsing to localhost:

nicholas@mordor:~$ 
nicholas@mordor:~$ lynx localhost --dump

Looking up localhost
Making HTTP connection to localhost
Alert!: Unable to connect to remote host.

lynx: Can't access startfile http://localhost/
nicholas@mordor:~$ 
nicholas@mordor:~$ lynx localhost/index.html --dump

Looking up localhost
Making HTTP connection to localhost
Alert!: Unable to connect to remote host.

lynx: Can't access startfile http://localhost/index.html
nicholas@mordor:~$ 
nicholas@mordor:~$ lynx localhost/50x.html --dump

Looking up localhost
Making HTTP connection to localhost
Alert!: Unable to connect to remote host.

lynx: Can't access startfile http://localhost/50x.html
nicholas@mordor:~$ 

Neither am I getting a welcome file from nginx as I'd expect.

1

Did you only try to reach localhost? Or even 0.0.0.0 or 127.0.0.1?

Depending on the operating system, docker config and the internal networking setup, some problem can occurs to reach the docker network.

You can inspect the container to get the network IP, maybe you can go there https://stackoverflow.com/a/20686101/2904965

3
  • I found the specific index.html file in the container, updated the file and restarted the container. voila. but, yes, I looked at the hosts file as well. I just manually copied the file into the container. – Nicholas Saunders Nov 14 '20 at 7:32
  • Mmhh, if you update a file in the container, and then you restart it, you should loose the modification, excepted if you mount this file as a volume. IMHO the problem to not access through network to localhost is depending on how docker is installed and on which OS. – Benjamin Longearet Nov 14 '20 at 8:42
  • huh. the container is supposed to revert back to an initial state?? because that didn't happen with nginx... – Nicholas Saunders Nov 14 '20 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.