title: Docker Containers NoRouteToHostException: Host is unreachable
body: <p>I am on CentOS-8 and have a couple of spring-boot services: demo-client calls demo-server over HTTP through spring RestTemplate. This works fine without Docker container.
  But when I deploy them as docker-compose with default network, demo-client is not able to call demo-server. I tried with service-name and also with ip-address of the container but same error in both cases:</p>
  
  <pre>
  demo-client_1  | 2020-02-29 10:23:55.165 ERROR 1 --- [nio-8082-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.client.ResourceAccessException: **I/O error on GET request for "http://172.24.0.2:8081/hello": Host is unreachable (Host unreachable);** nested exception is java.net.NoRouteToHostException: Host is unreachable (Host unreachable)] with root cause
  demo-client_1  | 
  demo-client_1  | java.net.NoRouteToHostException: Host is unreachable (Host unreachable)
  demo-client_1  |    at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_212]
  demo-client_1  |    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_212]*
  </pre>
  
  <p>Docker compose file :</p>
  
  <pre><code>docker-compose.yml:
  version: '3'
  services:
    demo-client:
      build: ./demo-client
      ports:
        - "8082:8082"
      depends_on:
        - demo-server
    demo-server:
      build: ./demo-server
      ports:
        - "8081:8081"
  </code></pre>
  
  <p>I tried following firewall related actions as suggested in some of the earlier posts:</p>
  
  <pre><code>sudo firewall-cmd --add-service=https --permanent
  sudo firewall-cmd --reload
  firewall-cmd --permanent --zone=trusted --add-interface=docker0
  firewall-cmd --reload
  service firewalld restart*
  </code></pre>
  
  <p>None of this worked. What I thought to be a straight forward thing turned out to be more complex.</p>