Search code examples
serviceinfrastructureconsuldevops

ServiceAddress is empty when using Consul Registrator


[
  {
    "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
  }
]

This is what I get from querying the Consul service API (/v1/catalog/service/service1).

Commands that I used to start registrator and services:

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

Any steps I'm doing wrong? How do you assign the hostname to ServiceAddress field?


Solution

  • I had similar issue and found that before v6 Consul Registrator leaves ServiceAddress empty, but in v6 (at the moment the latest) it is "0.0.0.0". I've tried to use "-ip" option but it did not help, somehow it assigns internal IP address of the container. Found related issues at:

    In my case I fixed it by binding container to IP address like:

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