gliderlabs / registrator

Service registry bridge for Docker with pluggable adapters
http://gliderlabs.com/registrator
MIT License
4.66k stars 912 forks source link

Why doesn't registrator respect the name given to services #479

Open babatundebusari opened 7 years ago

babatundebusari commented 7 years ago

I have noticed when i run services with docker, i provide them with names and yet when they register with consul, they have a different name

Why does registrator not respect the names of containers/services?

docker run -d --restart=always \
    --name=registrator \
    --net=host \
    --volume=/var/run/docker.sock:/tmp/docker.sock \
    gliderlabs/registrator:latest \
      consul://localhost:8500
isavcic commented 7 years ago

Which environment variables are you setting when running the containers?

babatundebusari commented 7 years ago

@isavcic

There are many services running that i gave specific names too but registrator registers them with consul with a totally different name than i gave

one example is consul-agent, the name of the serviceis consul-agent but registrator had it as consul-53

docker run -d --restart=always \
--name consul-agent --net host \
-v /opt/consul:/consul/data \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/consul/:/consul/config/ \
-h "microservices-agent-$(hostname)" \
-p 53:53/udp -p 53:53 \
consul agent -retry-join=10.247.1.83 -retry-join=10.247.1.85 -retry-join=10.247.1.86 \
-advertise 10.247.1.2 -datacenter us-pa-00
aboettger-tuhh commented 7 years ago

Try _ instead of -. That works in my case. The number 53 is the public port. If you use multiple ports, a service is registered for each port in Consul. I do not know what the advantage is, I do not like it.

babatundebusari commented 7 years ago

@aboettger-tuhh Use underscore _ to replace dash - where exactly?

aboettger-tuhh commented 7 years ago

--name consul_agent instead of --name consul-agent

babatundebusari commented 7 years ago

@aboettger-tuhh

So that means the name on consul will be consul_agent right? I mean its better than what it currently is at least but will be good to be able to name things with - as well

aboettger-tuhh commented 7 years ago

So that means the name on consul will be consul_agent right?

right :)