Pcornel
Containers · Container Networking

Container DNS Resolution

Cheat sheet · https://pcornel.dk/topic.php?topic=6132

Back to the Topic

Answer

Container DNS: Docker's embedded DNS (127.0.0.11) resolves container names on user-defined networks; Kubernetes CoreDNS resolves Service and pod names with search domains from the pod's resolv.conf.

Remember

In Kubernetes, ndots:5 makes short external names try cluster suffixes first — use FQDNs with a trailing dot for heavy external lookups. Check CoreDNS pods and logs.

First checks

  • docker ps -a — containers and exit codes
  • docker logs <c> — container output
  • docker inspect <c> — config, mounts, network, state

Commands

docker exec c cat /etc/resolv.conf
nslookup api
kubectl exec pod -- nslookup kubernetes.default
kubectl -n kube-system get pods -l k8s-app=kube-dns

Verify in this order

container resolver → embedded DNS/CoreDNS → cluster records or upstream

Where it usually breaks

A host that uses 127.0.0.53 (systemd-resolved) passes an unusable nameserver to containers on the default bridge.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6132

Confirmation

Confirm action

Continue?