1

I'm using https://hub.docker.com/_/centos/ CentOS 7 docker image. I created service with 3 replicas inside cluster and i'd like to query internal docker dns.

For BusyBox image nslookup works exactly in the same way as shown in documentation: https://docs.docker.com/engine/swarm/networking/#/use-swarm-mode-service-discovery):

nslookup tasks.my-web

Server:    127.0.0.11
Address 1: 127.0.0.11

Name:      tasks.my-web
Address 1: 10.0.0.8 my-web.2.2s1t73cy4m5oi4nadqjrsp0y9.cluster_net
Address 2: 10.0.0.9 my-web.3.2vu4qaxm5zkz56atmmvlm7iur.cluster_net
Address 3: 10.0.0.7 my-web.1.5dtqm90o8b4vgrli3z81axmyp.cluster_net

But with nslookup tool (packages: bind-libs-9.9.4-29.el7_2.4.x86_64, bind-utils-9.9.4-29.el7_2.4.x86_64) in CentOS 7 container I get a truncated result:

nslookup tasks.my-web

Server:         127.0.0.11
Address:        127.0.0.11#53

Non-authoritative answer:
Name:   tasks.my-web
Address: 10.0.0.9
Name:   tasks.my-web
Address: 10.0.0.7
Name:   tasks.my-web
Address: 10.0.0.8

I'd like to fix this.

UPD: I can get additional information using commands

nslookup 10.0.0.7
nslookup 10.0.0.8
nslookup 10.0.0.9

But I'm interested in more simple solution.

0

Only one-liner solution

dig +short tasks.$SERVICE_NAME | xargs -r -n 1 dig +short -x 

Output

my-web.2.2s1t73cy4m5oi4nadqjrsp0y9.cluster_net
my-web.3.2vu4qaxm5zkz56atmmvlm7iur.cluster_net
my-web.1.5dtqm90o8b4vgrli3z81axmyp.cluster_net

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.