Docker allocation cannot resolve *.consul DNS

Apologies if this question has been asked before, I feel like its a very common use case but I couldn’t find an answer.

Currently if I want my Docker containers to be able to resolve *.consul dns (ie myother-app.service.consul) I need to add this 2 parameters in the job -> group -> task-> config:

dns_servers = [

        dns_search_domains = [

I do this to each Nomad Job I have. I was wondering that there must be a better way to do this and avoid so much duplication.

Could some one point me in the right direction?


The thing ~ I did:

install dnsmasq, ensure it is listening on (for docker iface) or (but firewalled from public iface) on every nomad client and configure it to also ask consul for dns like:

# /etc/dnsmasq.d/10-consul

configure docker to use the gateway as dns server in containers

# /etc/docker/daemon.json
{"dns": [""]}