Answers: <p>Did you only try to reach localhost? Or even 0.0.0.0 or 127.0.0.1?</p>
  <p>Depending on the operating system, docker config and the internal networking setup, some problem can occurs to reach the docker network.</p>
  <p>You can inspect the container to get the network IP, maybe you can go there <a href="https://stackoverflow.com/a/20686101/2904965">https://stackoverflow.com/a/20686101/2904965</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2020-11-14T07:32:36.077Z
Answers: 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.
Answers: Nicholas Saunders
Answers: CC BY-SA 4.0
Answers: 2020-11-14T08:42:58.697Z
Answers: 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.
Answers: Benjamin Longearet
Answers: CC BY-SA 4.0
Answers: 2020-11-14T08:53:47.820Z
Answers: huh.  the container is supposed to revert back to an initial state?? because that didn't happen with nginx...
Answers: Nicholas Saunders
Answers: CC BY-SA 4.0
Answers: 2020-11-14T03:50:50.780Z
Answers: 2020-11-14T03:50:50.780Z
Answers: Benjamin Longearet
Body: <p>This <a href="https://devops.stackexchange.com/q/12752/23443">builds</a> and runs without apparent error:</p>
  <pre><code>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 
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Error&lt;/title&gt;
  &lt;style&gt;
      body {
          width: 35em;
          margin: 0 auto;
          font-family: Tahoma, Verdana, Arial, sans-serif;
      }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;An error occurred.&lt;/h1&gt;
  &lt;p&gt;Sorry, the page you are looking for is currently unavailable.&lt;br/&gt;
  Please try again later.&lt;/p&gt;
  &lt;p&gt;If you are the system administrator of this resource then you should check
  the error log for details.&lt;/p&gt;
  &lt;p&gt;&lt;em&gt;Faithfully yours, nginx.&lt;/em&gt;&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  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   &quot;/docker-entrypoint.…&quot;   5 minutes ago       Up 5 minutes        0.0.0.0:8080-&gt;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# 
  </code></pre>
  <p>Yet, there's no output when browsing to <code>localhost</code>:</p>
  <pre><code>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:~$ 
  </code></pre>
  <p>Neither am I getting a welcome file from <code>nginx</code> as I'd expect.</p>
  
Tags: <docker><docker-compose><dockerfile><nginx><servers>
Title: How to navigate to an index.html with nginx?
UserDisplayName: Nicholas Saunders
ThreadText: # How to navigate to an index.html with nginx?
  
  (Asked by: username_0 on 2020-11-14)
  
  This [builds](https://devops.stackexchange.com/q/12752/23443) and runs without apparent error:
  
  ```
  root@mordor:/home/username_0/docker/nginx# 
  root@mordor:/home/username_0/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/username_0/docker/nginx# 
  root@mordor:/home/username_0/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/username_0/docker/nginx# 
  root@mordor:/home/username_0/docker/nginx# ls
  dockerfile  index.html
  root@mordor:/home/username_0/docker/nginx# 
  root@mordor:/home/username_0/docker/nginx# cat dockerfile 
  FROM nginx
  COPY index.html /usr/share/nginx/html
  root@mordor:/home/username_0/docker/nginx# 
  root@mordor:/home/username_0/docker/nginx# cat index.html 
  
  hello world
  
  how do I put this file in a diff dir?
  
  root@mordor:/home/username_0/docker/nginx# 
  
  ```
  
  Yet, there's no output when browsing to `localhost`:
  
  ```
  username_0@mordor:~$ 
  username_0@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/
  username_0@mordor:~$ 
  username_0@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
  username_0@mordor:~$ 
  username_0@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
  username_0@mordor:~$ 
  
  ```
  
  Neither am I getting a welcome file from `nginx` as I'd expect.
  
  **Tags:** docker, docker-compose, dockerfile, nginx, servers
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-11-14. Score: 1 | Accepted answer
  
  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>
  
  > **Comments:**
  > **username_0**: 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.  
  > **username_1**: 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.  
  > **username_0**: huh.  the container is supposed to revert back to an initial state?? because that didn't happen with nginx...  
  
  ---
  
  