2016-10-28 67 views
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 

給出的鏈接,我應該能夠使用主機名discovery連接到eureka-server,像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),我無法呼叫我的註冊服務 是否有任何配置丟失呢?

回答

1

爲了訪問提供鏈接名稱解析的Rancher DNS,需要使用net:host將標籤io.rancher.container.dns:true添加到服務器。