【问题标题】:ServiceAddress is empty when using Consul Registrator使用 Consul Registrator 时 ServiceAddress 为空
【发布时间】:2015-04-29 05:02:48
【问题描述】:
[
  {
    "Node": "consul-staging-a-1.org",
    "Address": "10.0.11.221",
    "ServiceID": "mesos-slave-staging-a-1.org:determined_bartik:5000",
    "ServiceName": "service1",
    "ServiceTags": null,
    "ServiceAddress": "",
    "ServicePort": 4003
  },
  {
    "Node": "consul-staging-a-1.org",
    "Address": "10.0.11.221",
    "ServiceID": "mesos-slave-staging-a-1.org:angry_hypatia:5000",
    "ServiceName": "service1",
    "ServiceTags": null,
    "ServiceAddress": "",
    "ServicePort": 4007
  }
]

这是我通过查询 Consul 服务 API (/v1/catalog/service/service1) 得到的。

我用来启动注册器和服务的命令:

docker run -d  -v /var/run/docker.sock:/tmp/docker.sock -h $HOSTNAME gliderlabs/registrator consul://consul-staging-a-1.org:8500

docker run -d -p 4003:5000 -e "SERVICE_NAME=service1" docker-training/hello-world
docker run -d -p 4007:5000 -e "SERVICE_NAME=service1" docker-training/hello-world

我做错了什么步骤?如何将主机名分配给 ServiceAddress 字段?

【问题讨论】:

    标签: service infrastructure consul devops


    【解决方案1】:

    我有类似的问题,发现在 v6 Consul Registrator 将 ServiceAddress 留空之前,但在 v6(目前最新)中它是“0.0.0.0”。我尝试使用“-ip”选项,但它没有帮助,它以某种方式分配了容器的内部 IP 地址。在以下位置找到相关问题:

    在我的情况下,我通过将容器绑定到 IP 地址来修复它:

    docker run -d -p 10.0.0.3:4003:5000 -e "SERVICE_NAME=service1" docker-training/hello-world
    

    【讨论】:

      猜你喜欢
      • 2015-12-21
      • 2017-06-22
      • 2016-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-11
      • 2018-04-14
      • 2021-09-21
      相关资源
      最近更新 更多