Consul DNS returns containers IP instead of host IP

361 views
Skip to first unread message

Jojo Juju

unread,
Dec 17, 2015, 8:53:53 AM12/17/15
to Consul
Hi,

I have an issue with getting Consul DNS resolving correct service IP. Situation is as follows. I have Swarm cluster, 3 nodes, one of them is 10.25.46.173. Consul server is 10.24.26.135.

 I spun up container nginx on docker host 10.25.46.173

3b6b6d76fda5        nginx                         "nginx -g 'daemon off"   22 minutes ago      Up 22 minutes       443/tcp, 10.25.46.173:32772->80/tcp


Run docker agent client binary on docker host 10.25.46.173

[root@swrn001 ~]#./consul agent -data-dir /tmp -advertise 10.25.46.173 -client 10.25.46.173 -join 10.24.26.135 -dc testenv &>/dev/null &
[root@swrn001 ~]#./consul version
Consul v0.6.0
Consul Protocol: 3 (Understands back to: 1)

I spun up registrator as container on docker host 10.25.46.173:

[root@swrn001 ~]#docker run -d --name regdock01 -h docker01 -v /var/run/docker.sock:/tmp/docker.sock gliderlabs/registrator consul://10.25.46.173:8500
c0636cd3c0666a141a6c70649acffb517dcb70b043b9ca06e5abd42debf87302


Consul server says everything is OK:

[tomasv@consulsrv001 ~]$ consul members
Node             Address               Status  Type    Build  Protocol  DC
awsswrn001       10.25.46.173:8301     alive   client  0.6.0  2         testenv

Now, when i try to resolve nginx service, im getting IP of a docker container instead IP of a docker host (10.25.46.173) where particular nginx container resides:

tomasv@ThinkPad:~$ nslookup nginx-80.service.consul -port=8600 10.24.26.135
Server:        10.24.26.135
Address:    10.24.26.135#8600

Name:    nginx-80.service.consul
Address: 172.17.0.3

Any thoughts?

Thanks






Jojo Juju

unread,
Dec 17, 2015, 4:36:45 PM12/17/15
to Consul
Fixed. i have forced registrator to use host ip instead of internal by adding - ip <swarm_node_ip> switch.  see https://github.com/gliderlabs/registrator/issues/133
Reply all
Reply to author
Forward
0 new messages