【发布时间】:2018-07-01 20:53:54
【问题描述】:
我们有一个 docker-compose.yml 文件:
version: '3'
services:
consul:
container_name: consul
command: agent -dev -config-dir=/consul/config
dns: 8.8.8.8
hostname: consul-docker
image: docker-registry.mycompany.net/ap/consul-ent:0.9.2
ports:
- "8500:8500"
volumes:
- ./consul/config/conf.json:/consul/config/conf.json
# https://github.com/gliderlabs/registrator
registrator:
command: consul://consul:8500
container_name: registrator
depends_on:
- consul
image: gliderlabs/registrator:latest
restart: always
volumes:
- /var/run/docker.sock:/tmp/docker.sock
myservice1:
container_name: myservice1
image: docker-registry.mycompany.net/ap/myservice1/develop:latest
ports:
- "8080:8080"
- "5000:5000"
# more services below
当我使用 consul v1 API 转到 http://localhost:8500/v1/health/checks/myservice1 检查健康状态时,它返回一个空数组 []。
根据docker ps和myservice1的日志,myservice1已经Ready了。
myservice1 在http://localhost:8500/ui/#/dc1/services 上显示绿色
myservice1 是一个基于 dropwizard 的 java 微服务。
根据https://www.consul.io/api/health.html,示例回复
$ curl https://consul.rocks/v1/health/service/my-service
看起来像:
[
{
"Node": {
"ID": "40e4a748-2192-161a-0510-9bf59fe950b5",
"Node": "foobar",
"Address": "10.1.10.12",
"Datacenter": "dc1",
"TaggedAddresses": {
"lan": "10.1.10.12",
"wan": "10.1.10.12"
},
"Meta": {
"instance_type": "t2.medium"
}
},
"Service": {
"ID": "redis",
"Service": "redis",
"Tags": ["primary"],
"Address": "10.1.10.12",
"Port": 8000
},
"Checks": [
{
"Node": "foobar",
"CheckID": "service:redis",
"Name": "Service 'redis' check",
"Status": "passing",
"Notes": "",
"Output": "",
"ServiceID": "redis",
"ServiceName": "redis",
"ServiceTags": ["primary"]
},
{
"Node": "foobar",
"CheckID": "serfHealth",
"Name": "Serf Health Status",
"Status": "passing",
"Notes": "",
"Output": "",
"ServiceID": "",
"ServiceName": "",
"ServiceTags": []
}
]
}
]
根据注册者日志,它看到 myservice1 正常并添加了 myservice1。
任何关于我为什么会看到 [] 响应的想法将不胜感激?
【问题讨论】:
标签: docker docker-compose consul registrator