title: JHipster application in docker container cannot be accessed on host network, cannot communicate with other containers on non-host network
body: <p>I am trying to deploy my JHipster microservices and registry in docker containers on my OS X development machine.</p>
  
  <p>I deploy the registry using more or less the default docker-compose configuration JHipster provides out of the box:</p>
  
  <pre><code>version: '2'
  services:
      jhipster-registry:
          image: jhipster/jhipster-registry:v3.1.0
          volumes:
              - ./central-server-config:/central-config
          # When run with the "dev" Spring profile, the JHipster Registry will
          # read the config from the local filesystem (central-server-config directory)
          # When run with the "prod" Spring profile, it will read the configuration from a Git repository
          # See https://jhipster.github.io/microservices-architecture/#registry_app_configuration
          environment:
              - SPRING_PROFILES_ACTIVE=dev,native
              - SECURITY_USER_PASSWORD=admin
              - SPRING_CLOUD_CONFIG_SERVER_NATIVE_SEARCH_LOCATIONS=file:./central-config/localhost-config/
              # - GIT_URI=https://github.com/jhipster/jhipster-registry/
              # - GIT_SEARCH_PATHS=central-config
          ports:
              - 8761:8761
  </code></pre>
  
  <p>When I deploy my microservices using <code>docker run</code>, however, one of two things happens:</p>
  
  <p>If I publish the port I want to make the microservice available on using <code>-p 8080:8080</code> so I can access it through the browser, I can reach it but the microservice cannot find the registry. </p>
  
  <pre><code>Could not locate PropertySource: I/O error on GET request for "http://jhipster-registry:8761/config/clientaggregator/dev,twilio": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)
  </code></pre>
  
  <p>Meanwhile, I can view the  pages the registry serves fine.</p>
  
  <p>I can fix this by adding "--network=host" when starting the microservice. However, when I do that this apparently overrides the native-to-host port mapping and the microservice cannot be reached from the browser.</p>
  
  <p>What's more bizarre is that about a week ago I was using the exact same configuration, which worked fine.</p>
  
  <p><a href="https://i.stack.imgur.com/8ktSb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8ktSb.png" alt="enter image description here"></a></p>
  
  <p>If I run my application outside of a docker container, it connects to the registry fine. If I create a different container, or connect to the microservice container and access the configuration url via curl, I get a response.</p>