Container DNS failures versus service connectivity
Worked example
This is an offline lesson. Data are fictional and Docker commands are unexecuted. Any optional execution requires an authorized disposable VM, a verified context, synthetic data, restricted access and no external transmission. Do not collect secrets or private output. Treat the worksheet as evidence to analyze, not a script to paste. Before any authorized observation confirm the actual endpoint, object identity, time window and output budget. Do not repair, restart or delete resources during this offline exercise.
Fictional Compose topology:api and db share network bm-lab-backendA: db name does not resolve; api not attached to backendB: db resolves; db not listening on port 5432C: db resolves; TCP reaches service; database authentication failsD: api uses localhost:5432; db is a separate containerStaged checks for exact approved project:docker compose -p bm-lab psdocker network inspect bm-lab-backendFirst compare intended network membership and service name/alias. Compose services on a shared network can normally resolve one another by service name. In A correct the declared network relationship if approved, rather than hard-coding an address. In B check the listener, service startup and container port; DNS worked. In C follow the application authorization flow without logging credentials. In D localhost refers to the caller container under normal separate network namespaces, not db. A peer DNS check must run from the caller network context using an available trusted diagnostic tool; do not assume every minimal image has getent or curl and do not install tools from the Internet during a lab. A live connection test should be bounded and target only the approved synthetic service. Verify name resolution, connection and application response separately; roll back the network/config change if required. The topology heading describes the intended network, while A explicitly describes a deviation from that topology. A successful lookup does not prove TCP reachability; a successful TCP connection does not prove application authorization.
Common mistake
Never replace internal DNS with arbitrary public resolvers or hard-coded IP addresses before checking the intended network and service.
Manual practice
Map A–D to network membership, listener, application access or incorrect endpoint. Write the smallest check that distinguishes each from DNS failure.
Worksheet: lab-fixtures/docker-troubleshooting/08-dns/scenario.txt.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Container DNS failures versus service connectivity — Knowledge check
Interpret synthetic incident evidence and choose safe diagnostic actions.
db resolves but TCP cannot connect. What should be investigated next?
What does localhost normally refer to inside api?
A TCP connection succeeds but database authentication fails. Which layer?