consul注册地址问题


按照((http://gliderlabs.com/registra ... start/))测试Docker服务发现功能,
我有两台机器10.18.35.52和10.18.35.51

10.18.35.52启动consul server:

docker run -d --name=consul --net=host gliderlabs/consul-server -bootstrap -bind=10.18.35.152

10.18.35.51上启动registrator和启动一个redis容器

docker run -d --name=registrator --net=host -v /var/run/docker.sock:/tmp/docker.sock gliderlabs/registrator:latest consul://10.18.35.152:8500

docker run -d -P --name=redis redis

问题:这时我查看10.18.35.152上的redis注册信息,发现redis的注册地址Address不是10.18.35.151,而是10.18.35.152,这是怎么回事?

curl http://10.18.35.152:8500/v1/catalog/service/redis
[{"Node":"jssc-docker-152","Address":"10.18.35.152","ServiceID":"jssc-docker-151:redis:6379","ServiceName":"redis","ServiceTags":[],"ServiceAddress":"","ServicePort":32768,"ServiceEnableTagOverride":false,"CreateIndex":46,"ModifyIndex":46}]
已邀请:

kine

赞同来自:


ServiceAddress":"没有值,所以取了node的Address。
// Get the address of the service, falling back to the address of the node.
var address string
if entry.Service.Address != "" {
address = entry.Service.Address
} else {
address = entry.Node.Address
}

要回复问题请先登录注册