0

我有一个服务发现和一个客户端在 Rancher 中注册到这个服务器。它是这样的:

eureka-server:
  ports:
  - 8761:8761/tcp
  labels:
    io.rancher.container.pull_image: always
    io.rancher.container.start_once: 'true'
  tty: true
  image: luizkowalski/eureka-server
  stdin_open: true
  net: host
edge-server:
  ports:
  - 8080:8080/tcp
  labels:
    io.rancher.container.pull_image: always
    io.rancher.container.start_once: 'true'
  tty: true
  image: luizkowalski/edge-server
  links:
  - eureka-server:discovery
  stdin_open: true
  net: host

给定链接,我应该能够eureka-server使用 hostname连接discovery,就像http://discovery:8761/eureka但我得到了

10/28/2016 2:04:55 PMCaused by: java.net.UnknownHostException: discovery
10/28/2016 2:04:55 PM   at java.net.InetAddress.getAllByName0(InetAddress.java:1280) ~[na:1.8.0_92-internal]
10/28/2016 2:04:55 PM   at java.net.InetAddress.getAllByName(InetAddress.java:1192) ~[na:1.8.0_92-internal]
10/28/2016 2:04:55 PM   at java.net.InetAddress.getAllByName(InetAddress.java:1126) ~[na:1.8.0_92-internal]
10/28/2016 2:04:55 PM   at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45) ~[httpclient-4.5.2.jar!/:4.5.2]
10/28/2016 2:04:55 PM   at org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:262) ~[httpclient-4.5.2.jar!/:4.5.2]
10/28/2016 2:04:55 PM   at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:161) ~[httpclient-4.5.2.jar!/:4.5.2]
10/28/2016 2:04:55 PM   at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144) ~[httpclient-4.5.2.jar!/:4.5.2]

当我managed在 Rancher 中使用网络时它可以工作,但结果是,我的服务发现将我的内部 ips 暴露给负载均衡器(172.xxx.xxx.xx)并且我无法调用我的注册服务是否缺少任何配置?

4

1 回答 1

1

为了访问提供链接名称解析的 Rancher DNS,您需要io.rancher.container.dns:true使用 net:host 将标签添加到服务器。

于 2016-10-29T21:29:45.370 回答