我有几个服务的docker-compose文件:
services:
consul:
image: consul:latest
ports:
- "8300:8300"
- "8301:8301"
- "8302:8302"
- "8400:8400"
- "8500:8500"
- "8600:53/udp"
command: "agent -server -ui -bootstrap-expect=1 -client=0.0.0.0"
microservice1:
image: xxx:latest
ports:
- "8080"
microservice2:
image: yyy:latest
ports:
- "8080"
服务已在Consul成功注册,健康检查正在通过。 我扩大了一个微服务: docker-compose up microservice1 = 3
所有新容器都在领事中正确显示。
但是,当我缩小微服务时,我在Consul中有橙色状态,日志显示如下:
2016/07/28 18:58:38 [WARN]代理:http请求失败 ' http://27dd6662f944:8080/health':得到 http://27dd6662f944:8080/health:拨打tcp:lookup 27dd6662f944 127.0.0.11:53:没有这样的主持人
有人知道如何解决这个问题吗?
答案 0 :(得分:0)
我找到了解决方案:
services:
consul:
**hostname: consul**
image: consul:latest
ports:
- "8300:8300"
- "8301:8301"
- "8302:8302"
- "8400:8400"
- "8500:8500"
- "8600:53/udp"
command: "agent -server -ui -bootstrap-expect=1 -client=0.0.0.0"
microservice1:
image: xxx:latest
ports:
- "8080"
microservice2:
image: yyy:latest
ports:
- "8080"
为consul image添加主机名...