title: Docker is not exposing application outside container when used host network mode however it works well within container
body: <p>I have a spring boot application which calls redis internally .
  I have redis running on 6379 inside docker container (also be accessed outside container through redis client)
  But When I expose the application as below it complains that redis connection failure . 
  Running on 8086   </p>
  
  <p><strong>docker run -d --name containerName -p 8086:8086 containerName:version</strong>
  But Application is accessible from browser as <a href="http://localhost:8086" rel="nofollow noreferrer">http://localhost:8086</a> 
  However when run like below with --net=host it works perfectly fine with warning as 
  WARNING: Published ports are discarded when using host network mode</p>
  
  <p><strong>docker run --rm -it -d --net=host --publish-all=true --name containerName containerName:version</strong></p>
  
  <p>But application is not accessible from browser <a href="http://localhost:8086" rel="nofollow noreferrer">http://localhost:8086</a></p>
  
  <p><strong>Exception stack trace</strong></p>
  
  <p>Exception in thread "pool-2-thread-1" org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
          at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:282)
          at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:476)
          at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:134)</p>
  
  <p><strong>Caused by: java.net.ConnectException: Connection refused (Connection refused)</strong>
          at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)</p>
  
  <p><strong>Note: I am Running docker container on windows machine</strong></p>