title: How to access "http://localhost" from a Docker container in Windows?
body: <p>I have a set of containers running in Windows 10 with Docker, this is the output of <code>docker-compose ps</code>:</p>
  
  <pre><code>&gt; docker-compose ps
       Name                    Command               State                          Ports
  --------------------------------------------------------------------------------------------------------------
  db_mysql          docker-entrypoint.sh mysqld      Up      3306/tcp
  elk               /usr/bin/supervisord -n -c ...   Up      0.0.0.0:81-&gt;80/tcp
  php71-fpm-nginx   /config/bootstrap.sh             Up      443/tcp, 0.0.0.0:80-&gt;80/tcp, 0.0.0.0:9001-&gt;9001/tcp
  </code></pre>
  
  <p>And this is the output of <code>docker inspect</code>:</p>
  
  <pre><code>&gt; docker inspect php71-fpm-nginx
  [
      {
          ...
              "NetworkMode": "anotherlampdocker_default",
              "PortBindings": {
                  "80/tcp": [
                      {
                          "HostIp": "",
                          "HostPort": "80"
                      }
                  ],
                  "9001/tcp": [
                      {
                          "HostIp": "",
                          "HostPort": "9001"
                      }
                  ]
              },
          ...
          "Mounts": [
              {
                  "Source": "/d/Development/www",
                  "Destination": "/data/www",
                  "Mode": "rw",
                  "RW": true,
                  "Propagation": "rprivate"
              },
              ...
          "NetworkSettings": {
              "Bridge": "",
              "SandboxID": "b96cf4c0f2c17d65659c31982b9200a79cca6f1c214770d31938204c493a6720",
              "HairpinMode": false,
              "LinkLocalIPv6Address": "",
              "LinkLocalIPv6PrefixLen": 0,
              "Ports": {
                  "443/tcp": null,
                  "80/tcp": [
                      {
                          "HostIp": "0.0.0.0",
                          "HostPort": "80"
                      }
                  ],
                  "9001/tcp": [
                      {
                          "HostIp": "0.0.0.0",
                          "HostPort": "9001"
                      }
                  ]
              },
              ...
              "Networks": {
                  "anotherlampdocker_default": {
                      "IPAMConfig": null,
                      "Links": [
                          "db_mysql:db",
                          "db_mysql:db_mysql"
                      ],
                      "Aliases": [
                          "php-fpm",
                          "248e8c254eee"
                      ],
                      "NetworkID": "de1e10b63e6e5050809af59ac4d26b7cb691afd5805d1cf7f0492c702814f34d",
                      "EndpointID": "ccec71967c6100c5a9f3ad82d82bbb2a371f77e12c493bf05bfd15f2d188ce00",
                      "Gateway": "172.18.0.1",
                      "IPAddress": "172.18.0.3",
                      "IPPrefixLen": 16,
                      "IPv6Gateway": "",
                      "GlobalIPv6Address": "",
                      "GlobalIPv6PrefixLen": 0,
                      "MacAddress": "02:42:ac:12:00:03"
                  }
              }
          }
      }
  ]
  </code></pre>
  
  <p>I am trying to access <code>http://localhost</code> but I can't. I've tried also using the container IP meaning <code>http://172.18.0.3</code> and doesn't work either. </p>
  
  <p>When I say I can't it means the following message:</p>
  
  <blockquote>
    <p>This site can’t be reached
    172.18.0.3 took too long to respond.</p>
  </blockquote>
  
  <p>The same container works perfectly in Linux.</p>
  
  <p>This is the content of <code>c:\Windows\System32\drivers\etc\hosts</code> file:</p>
  
  <pre><code># localhost name resolution is handled within DNS itself.
      127.0.0.1       localhost
  </code></pre>
  
  <p>The ports from the container are mapped to the host in the <code>docker-compose.yml</code> file:</p>
  
  <pre><code>services:
    php-fpm:
      container_name: "php71-fpm-nginx"
      build: php-fpm
      ports:
          - 80:80
          - 9001:9001
      environment:
          PHP_ERROR_REPORTING: 'E_ALL &amp; ~E_DEPRECATED &amp; ~E_NOTICE'
          STATUS_PAGE_ALLOWED_IP: '127.0.0.1'
      volumes:
          - D:\Development\www\:/data/www
  </code></pre>
  
  <p>What I am missing here?</p>