registrator: Hosts IP Address Incorrect
- What version of docker are you running?
Client:
Version: 1.12.1
API version: 1.24
Go version: go1.6.3
Git commit: 23cf638
Built: Thu Aug 18 05:33:38 2016
OS/Arch: linux/amd64
Server:
Version: 1.12.1
API version: 1.24
Go version: go1.6.3
Git commit: 23cf638
Built: Thu Aug 18 05:33:38 2016
OS/Arch: linux/amd64
- What version of registrator are you running?
gliderlabs/registrator:latest
- Did you build a custom version of registrator? If so, what is that image? No
- What is the exact command you are running registrator with?
docker run -d \
--name=registrator \
--net=host \
--volume=/var/run/docker.sock:/tmp/docker.sock \
gliderlabs/registrator:latest \
consul://10.44.0.173:8500
- What is the exact command you are running your container with?
docker run --rm -it \
--network=bridge \
--volume=/var/log/riemann-bridge:/log \
-p :5555 \
my-docker-riemann:latest
- A log capture of all the docker events before, during, and after the issue.
2016/10/06 09:55:27 added: 660d29892e28 ip-10-4-38-156:big_brahmagupta:5555
Description of the problem:
Registrator registers services using containers ip instead of hosts.
In consul service address appears as 172.17.0.4, where it should be 10.4.38.156.
...
"Service": {
"ID": "ip-10-4-38-156:big_brahmagupta:5555",
"Service": "docker-riemann",
"Tags": null,
"Address": "172.17.0.4",
"Port": 32786,
"EnableTagOverride": false,
"CreateIndex": 586,
"ModifyIndex": 586
}
...
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 1
- Comments: 27
I just wonder why I have to set
-ip,registratorcoundn’t get the host ip even if--net=hostis set?I faced this issue today for my AWS-ECS cluster. Until this issue gets fixed, here is a solution that might help some people. More information can be found in my stackoverflow post.
I modified my Dockerfile to execute a script at entrypoint and in that script I made the call to EC2 metadata service to get LOCAL_IP.
Dockerfile
entrypoint.sh
You will notice the
if-elsecondition above. If the curl command is a success, I am setting theipflag inside so that I don’t have to pass the IP address in thecmdsection. But for local testing where this curl command would fail, I am not setting any flags, and I will pass theipflag in thecmdsection.Ended up using
-ipflag, since I think registrator is having trouble picking up the right interface once dockerized.Perhaps a good solution would be to pass
REGISTRATOR_INTERFACEor similar env variable, to specify which interface to inspect.Consul has this in their dockers
ENTRYPOINTscript.Sorry gave you wrong command
it has to be passed to registrator rather than docker