Service names & DNS - Im so close

Hello all~

Getting used to swarm and really enjoy it so far. We are going to use in our production environment and I have one final hangup when it comes to DNS and the services/workers.

I have a service created called testService with 4 replicas on two different nodes.

Which when looking at docker ps gives individual service names like:
testService.1.;lkajsh8324
testService.2.l;km,.bnljkoiu
testService.3.tuoiughm,ncv
testService.4.jajbjbm,jfjkasdf

I can resolve testService, cannot resolve testService.1, but can resolve testService.1.jjfkalkdjfaiuo

But I feel I must be doing some wrong because the names have the format “serviceName.instance#.someId” when I would expect them to be in the format “serviceName.instance#”. Am I doing something wrong or am I mis-reading documentation?

I am not sure I can use this docker swarm system with overlay network if I cannot always assume my four services will have DNS resolution of testService.1, testService.2, testSErvice.3, testService.4

Can someone please point out a missing config option or tell me what those ids on the last part of the service name is please? I am trying to build a fully fault tolerant system with docker and I really need those dns entries to always be consistent. Thank you for your time.

jb

I have also been looking for a way to look up each individual instance of a service via DNS (I currently use VIP addressing).

A partial answer to your question might be to do an “nslookup” or “dig” on “tasks.servicename”. This always seems to give multiple A records - one for each instance of the service along with the associated IP for that instance.

This, unfortunately, is not useful for me since I need an individual hostname for each instance, but it may help you.

Check out using service template to create an env variable to get the current containers service name.