Pcornel
Browse topics
Options
Recent
Favorites
Containers · Technical reference

Container DNS Resolution

Direct 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.

When to use this

Use it when names do not resolve inside containers.

First 30 seconds

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.

Operational verification

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

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Docker / containerd / Podman / Kubernetes / OCI-compatible platforms
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformDocker / containerd / Podman / Kubernetes / OCI-compatible platforms
Scope / prerequisiteUse it when names do not resolve inside containers.
What next?2 suggested next steps
Evidence0
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

3 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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
EnvironmentResolverCheck
Docker user-defined network127.0.0.11 (embedded)docker exec c cat /etc/resolv.conf, nslookup api
KubernetesCoreDNS 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.

Key points

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.

Key checks
  • docker ps -a — containers and exit codes
  • docker logs <c> — container output
  • docker 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

NameResolves to
webService web in the Pod's own namespace
web.shopService web in namespace shop
web.shop.svc.cluster.localSame, fully qualified
db-0.db.shop.svc.cluster.localStatefulSet 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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Common mistakes

  • Hard-coding container IP addresses.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terminology layer

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.

Aliases that resolve here
container dns resolutioncontainer dns resolv.confcoredns ndots
Confirmation

Confirm action

Continue?