Use it when names do not resolve inside containers.
Container DNS Resolution
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.
1. Inside: cat /etc/resolv.conf.
2. nslookup <svc>.<ns>.svc.cluster.local.
3. CoreDNS pods running: kubectl -n kube-system get pods -l k8s-app=kube-dns.
4. CoreDNS logs/forwarders.
5. Docker: user-defined network for name resolution.
container resolver → embedded DNS/CoreDNS → cluster records or upstream
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 How to verify Verify boundary
Query a cluster name (kubernetes.default) and an external name separately. Check CoreDNS logs for errors and its forward configuration in the coredns ConfigMap. Compare results with a fully qualified name ending in a dot.
Step 2 Troubleshooting DNS Narrow the fault
| Environment | Resolver | Check |
|---|---|---|
| Docker user-defined network | 127.0.0.11 (embedded) | docker exec c cat /etc/resolv.conf, nslookup api |
| Kubernetes | CoreDNS service (kube-dns) | kubectl exec pod -- nslookup kubernetes.default |
Kubernetes ndots:5 makes short names try search domains first; use FQDNs with a trailing dot for external names in latency-sensitive apps. Check CoreDNS logs and kubectl -n kube-system get pods -l k8s-app=kube-dns.
Step 3 Common failures Narrow the fault
A host that uses 127.0.0.53 (systemd-resolved) passes an unusable nameserver to containers on the default bridge. High ndots causes extra lookups and latency for external names. dnsPolicy: Default makes Pods use the node's resolver and lose cluster names.
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.
docker ps -a— containers and exit codesdocker logs <c>— container outputdocker inspect <c>— config, mounts, network, state
ReferenceWhat it is1 section · depth on demand
How it works
The runtime writes /etc/resolv.conf when the container starts. Docker's embedded DNS answers container names and forwards other queries to the host's resolvers. In Kubernetes, the kubelet writes the cluster DNS IP; CoreDNS answers Service names and forwards the rest upstream.
ReferenceImportant terms & boundaries2 sections · depth on demand
In depth
Kubernetes Pods normally get a resolver configuration that points at the cluster DNS Service (CoreDNS) with a search path for their namespace:
nameserver 10.96.0.10
search app.svc.cluster.local svc.cluster.local cluster.local
options ndots:5
What ndots:5 does
A name with fewer than five dots is tried with every search suffix first. api.example.com (two dots) is therefore queried as api.example.com.app.svc.cluster.local, then …svc.cluster.local, then …cluster.local, and only then as-is. Each attempt is an A and an AAAA query. For workloads that call many external names, use fully qualified names with a trailing dot (api.example.com.) or lower ndots in dnsConfig.
Names that resolve inside a cluster
| Name | Resolves to |
|---|---|
web | Service web in the Pod's own namespace |
web.shop | Service web in namespace shop |
web.shop.svc.cluster.local | Same, fully qualified |
db-0.db.shop.svc.cluster.local | StatefulSet Pod via headless Service db |
Worked check from inside a Pod
kubectl run dnsprobe --rm -it --image=busybox:1.36 --restart=Never -- sh
nslookup kubernetes.default # cluster DNS works?
nslookup example.com # forwarding to upstream works?
cat /etc/resolv.conf
Cluster names failing points at CoreDNS or its Service; external names failing alone points at the forward target in the CoreDNS Corefile or at egress filtering.
Common mistakes
- Hard-coding container IP addresses.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.