title: Cannot connect to jhipster spring registry on docker via IDE
body: <p>I'm running JHipster registry in a docker container.
  All applications <strong>running on docker</strong> can connect and register in registry endpoint (port 8761).</p>
  
  <p>But when I try to connect an application running on my IDEA, I receive a error when trying to connect to the registry endpoint:</p>
  
  <pre><code>2016-07-21 10:35:24.912  INFO 1455 --- [  restartedMain] a.b.p.App2App             : Started App2App in 14.944 seconds (JVM running for 15.912)
  2016-07-21 10:35:24.913  INFO 1455 --- [  restartedMain] a.b.p.App2App             : 
  ----------------------------------------------------------
      Application 'app2' is running! Access URLs:
      Local:      http://127.0.0.1:8081
      External:   http://192.168.1.104:8081
  ----------------------------------------------------------
  2016-07-21 10:35:24.913  INFO 1455 --- [  restartedMain] a.b.p.App2App             : 
  ----------------------------------------------------------
      Config Server:  Connected to the JHipster Registry running in Docker
  ----------------------------------------------------------
  2016-07-21 10:35:24.915 DEBUG 1455 --- [nfoReplicator-0] s.n.www.protocol.http.HttpURLConnection  : sun.net.www.MessageHeader@33e72d406 pairs: {GET /config/application/prod/master HTTP/1.1: null}{Accept: application/json, application/*+json}{Authorization: Basic YWRtaW46YWRtaW4=}{User-Agent: Java/1.8.0_65}{Host: localhost:8761}{Connection: keep-alive}
  2016-07-21 10:35:25.057 DEBUG 1455 --- [nfoReplicator-0] s.n.www.protocol.http.HttpURLConnection  : sun.net.www.MessageHeader@d6320d811 pairs: {null: HTTP/1.1 200 OK}{Server: Apache-Coyote/1.1}{X-Content-Type-Options: nosniff}{X-XSS-Protection: 1; mode=block}{Cache-Control: no-cache, no-store, max-age=0, must-revalidate}{Pragma: no-cache}{Expires: 0}{X-Application-Context: jhipster-registry:dev,native:8761}{Content-Type: application/json;charset=UTF-8}{Transfer-Encoding: chunked}{Date: Thu, 21 Jul 2016 13:35:24 GMT}
  2016-07-21 10:35:25.058  INFO 1455 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_APP2/app2:cddc722884843f95abdcf09d4996623d: registering service...
  2016-07-21 10:35:25.059 ERROR 1455 --- [nfoReplicator-0] c.n.d.s.t.d.RedirectingEurekaHttpClient  : Request execution error
  
  com.sun.jersey.api.client.ClientHandlerException: java.net.UnknownHostException: registry
      at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187)
      at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123)
      at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27)
      at com.sun.jersey.api.client.Client.handle(Client.java:652)
      at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682)
      at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
      at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:570)
      at com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.register(AbstractJerseyEurekaHttpClient.java:56)
      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59)
      at com.netflix.discovery.shared.transport.decorator.MetricsCollectingEurekaHttpClient.execute(MetricsCollectingEurekaHttpClient.java:73)
      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59)
      at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.executeOnNewServer(RedirectingEurekaHttpClient.java:118)
      at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.execute(RedirectingEurekaHttpClient.java:79)
      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59)
      at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:119)
      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59)
      at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77)
      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
      at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:810)
      at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:103)
      at com.netflix.discovery.InstanceInfoReplicator$1.run(InstanceInfoReplicator.java:87)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: java.net.UnknownHostException: registry
      at java.net.InetAddress.getAllByName0(InetAddress.java:1280)
      at java.net.InetAddress.getAllByName(InetAddress.java:1192)
      at java.net.InetAddress.getAllByName(InetAddress.java:1126)
      at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
      at org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:259)
      at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:159)
      at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144)
      at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:131)
      at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
      at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
      at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:882)
      at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:117)
      at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
      at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:173)
      ... 30 common frames omitted
  
  2016-07-21 10:35:25.059  WARN 1455 --- [nfoReplicator-0] c.n.d.s.t.d.RetryableEurekaHttpClient    : Request execution failure
  2016-07-21 10:35:25.060  WARN 1455 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_APP2/app2:cddc722884843f95abdcf09d4996623d - registration failed Cannot execute request on any known server
  
  com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
      at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:111)
      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59)
      at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77)
      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
      at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:810)
      at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:103)
      at com.netflix.discovery.InstanceInfoReplicator$1.run(InstanceInfoReplicator.java:87)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  
  2016-07-21 10:35:25.060  WARN 1455 --- [nfoReplicator-0] c.n.discovery.InstanceInfoReplicator     : There was a problem with the instance info replicator
  
  com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
      at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:111)
      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59)
      at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77)
      at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
      at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:810)
      at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:103)
      at com.netflix.discovery.InstanceInfoReplicator$1.run(InstanceInfoReplicator.java:87)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>The application connects to Register (see it in logs), but after that I receive the error:</p>
  
  <pre><code>UnknownHostException: registry
  </code></pre>
  
  <p>Did anyone know how can I connect to a registry running in docker?</p>
  
  <p>My spring application.yml is:</p>
  
  <pre><code>eureka:
      instance:
          prefer-ip-address: true
      client:
          enabled: true
          healthcheck:
              enabled: true
          registerWithEureka: true
          fetchRegistry: true
          serviceUrl:
              defaultZone: http://admin:admin@localhost:8761/eureka/
  </code></pre>
  
  <p>The default zone in jhipster-registry is <a href="http://user:pass@register:8761/eureka" rel="nofollow">http://user:pass@register:8761/eureka</a>.</p>
  
  <p>If I change to localhost, like this:</p>
  
  <pre><code>eureka:
      client:
          serviceUrl:
              defaultZone: http://admin:admin@localhost:8761/eureka/
  </code></pre>
  
  <p>It works, but in this case the services running in docker can't access the registry (reverse problem).</p>
  
  <p>Thanks!</p>