title: Docker container cannot connect to host machine: No route to host
body: <p>I've been trying to setup a docker environment using docker compose. One issue that has me stumped is that my docker containers cannot reach my host machine.</p>
  
  <p>I setup a container using the following compose file:</p>
  
  <pre><code>version: '3'
  services:
    webapp:
      image: ...
      ports:
        - "8080:8080"
  </code></pre>
  
  <p>When I enter the container, I am able to ping my host machine:</p>
  
  <pre><code>ping ${dockerHostIP}
  </code></pre>
  
  <p>However when I  try and retrieve the home page using curl inside the container:</p>
  
  <pre><code>curl http://${dockerHostIP}:8080
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>curl: (7) Failed connect to ${dockerHostIP}:8080; No route to host
  </code></pre>
  
  <p>I cannot figure out what should be done to resolve this No route to host error. Unfortunately I need to be able to do this as the web application makes requests using its hostname internally.</p>
  
  <p>Traceroute Results:</p>
  
  <pre><code>traceroute ${dockerHostIP}
  traceroute to ${dockerHostIP} (${dockerHostIP}), 30 hops max, 60 byte packets
   1  ${dockerHostName} (${dockerHostIP})  0.039 ms !X  0.012 ms !X  0.007 ms !X
  </code></pre>