DNS queries in Docker not hitting cache

2.6k views Asked by At

I'm using Container-Optimized OS from Google to run one of my Docker containers. I have seen that amount of my DNS queries to Google Cloud DNS is really high (billions) and it super strange. I it only for internal DNS queries.

So after trying to perform dig from inside on of the containers I have seen it always performs a query to nameserver (from /etc/resolve.conf its Googles nameserver 169.254.169.254 )

So each query it still performs a query to nameserver without hitting the cache even once.

So I went and checked how it works on ubuntu instances and it works fine there. Also checked deployments on kubernetes and they hitting cache from kube-dns as expected.

Is there is a way to solve it? I'm getting billions of queries instead of using the right TTL of DNS that getting ignored in this case.

1

There are 1 answers

5
John Hanley On

169.254.169.254 is not a nameserver. That is the virtualized IP address of the resolver which forwards requests to a DNS server.

If you want to cache queries, then you must configure a caching resolver inside your container. Look into products like dnsmasq.