Debugging Network Issues (nslookup, dig, curl, netshoot container)
Debug DNS and connectivity with dig, curl, and the netshoot toolbox container.
In plain words
Use the affected container’s namespace so diagnostics observe the same DNS, routes and iptables decisions as the failing process.
Think of it like…
Network debugging is following a letter: first validate the address, then the road, then the mailbox before blaming the letter writer.
Where you’ve seen it
In practice, docker run --rm --network shop nicolaka/netshoot bash -c "dig +short db; nc -vz db 5432; curl -sv http://api:8080/health" is the concrete move for this job: debug DNS and connectivity with dig, curl, and the netshoot toolbox container. The release is not accepted until repeat from the failing app container with the same network and compare DNS result, port test and application status separately confirms the result.
Words you’ll hear
- DNS Debug
- The implementation control in
docker run --rm --network shop nicolaka/netshoot bash -c "dig +short db; nc -vz db 5432; curl -sv http://api:8080/health"for debug DNS and connectivity with dig, curl, and the netshoot toolbox container. - curl
- The result to observe with
repeat from the failing app container with the same network and compare DNS result, port test and application status separately, rather than infer from a successful command alone. - netshoot
- The production boundary exposed when debugging only localhost, or reporting “DNS is down” from a TCP timeout without an explicit name lookup result.
Visual diagram
Theory & deep dive
DNS Debug control path
The concrete mechanism is docker run --rm --network shop nicolaka/netshoot bash -c "dig +short db; nc -vz db 5432; curl -sv http://api:8080/health". The observable result is repeat from the failing app container with the same network and compare DNS result, port test and application status separately; if those disagree, inspect the runtime evidence before changing unrelated settings.
Debug DNS and connectivity with dig, curl, and the netshoot toolbox container. Keep DNS Debug, curl and netshoot in the same deployment record so the intent and the observed state cannot drift apart.
docker run --rm --network shop nicolaka/netshoot bash -c "dig +short db; nc -vz db 5432; curl -sv http://api:8080/health"
repeat from the failing app container with the same network and compare DNS result, port test and application status separately, not with command success alone.netshoot failure boundary
A successful host curl does not prove container DNS or network attachment. Installing curl into the production image changes state; an ephemeral --network container can test the peer but will see a different network set if attached incorrectly. The narrow failure to design for is debugging only localhost, or reporting “DNS is down” from a TCP timeout without an explicit name lookup result.
Accept this compromise explicitly: A disposable toolbox is fast and clean; permanent observability is necessary to correlate intermittent multi-host failures over time. The controlled check-repeat from the failing app container with the same network and compare DNS result, port test and application status separately-also identifies the point where a different design is safer.
Exercise this failure safely: debugging only localhost, or reporting “DNS is down” from a TCP timeout without an explicit name lookup result.
How it works, step by step
Step 1 of 41. State the boundary
Write down why the workload needs this: A successful host curl does not prove container DNS or network attachment. Installing curl into the production image changes state; an ephemeral --network container can test the peer but will see a different network set if attached incorrectly.
- Intent
- DNS Debug
When to use it & trade-offs
What it is
Start network debugging in layers: name resolution with nslookup/dig, TCP reachability with curl or nc, listener with ss, route with ip route, then policy with firewall/captures. netshoot supplies tools without permanently adding them to the application image.
Why it matters: A successful host curl does not prove container DNS or network attachment. Installing curl into the production image changes state; an ephemeral --network container can test the peer but will see a different network set if attached incorrectly.
When to reach for it
- The fit is strongest for this job: debug DNS and connectivity with dig, curl, and the netshoot toolbox container. Pair it with
repeat from the failing app container with the same network and compare DNS result, port test and application status separatelyin the runbook. - Production DNS Debug changes should make curl observable through
docker run --rm --network shop nicolaka/netshoot bash -c "dig +short db; nc -vz db 5432; curl -sv http://api:8080/health", rather than trusting the runtime default. - Keep a rollback example for the case where debugging only localhost, or reporting “DNS is down” from a TCP timeout without an explicit name lookup result.
When to avoid or be careful
- Do not accept command success while the system can still fail by debugging only localhost, or reporting “DNS is down” from a TCP timeout without an explicit name lookup result.
- Avoid erasing netshoot protection merely to dodge this cost: “A disposable toolbox is fast and clean; permanent observability is necessary to correlate intermittent multi-host failures over time”.
- Do not replace the evidence path-
repeat from the failing app container with the same network and compare DNS result, port test and application status separately-with a screenshot or a mutable tag.
docker run --rm --network shop nicolaka/netshoot bash -c "dig +short db; nc -vz db 5432; curl -sv http://api:8080/health": practical choices
Strengths: Start network debugging in layers: name resolution with nslookup/dig, TCP reachability with curl or nc, listener with ss, route with ip route, then policy with firewall/captures. netshoot supplies tools without permanently adding them to the application image.
Watch out: A disposable toolbox is fast and clean; permanent observability is necessary to correlate intermittent multi-host failures over time.
Strengths: It can begin with docker run --rm --network shop nicolaka/netshoot bash -c "dig +short db; nc -vz db 5432; curl -sv http://api:8080/health" and fewer surrounding controls.
Watch out: It silently accepts debugging only localhost, or reporting “DNS is down” from a TCP timeout without an explicit name lookup result, which makes the result hard to reproduce after promotion.
Strengths: A successful host curl does not prove container DNS or network attachment. Installing curl into the production image changes state; an ephemeral --network container can test the peer but will see a different network set if attached incorrectly.
Watch out: The platform adds an ownership and debugging layer; retain repeat from the failing app container with the same network and compare DNS result, port test and application status separately as the direct check.
Interview signals & numbers to know
When this topic comes up
- docker run --rm --network shop nicolaka/netshoot bash -c "dig +short db; nc -vz db 5432; curl -sv http://api:8080/health"
- repeat from the failing app container with the same network and compare DNS result, port test and application status separately
- Failure signature: debugging only localhost, or reporting “DNS is down” from a TCP timeout without an explicit name lookup result
- Trade-off: A disposable toolbox is fast and clean; permanent observability is necessary to correlate intermittent multi-host failures over time.
Benchmarks & rules of thumb
- 4 layers
- name, route, socket and application
- 53
- DNS port
- 5432 and 8080
- two different service checks in the example
Common mistakes & follow-ups
Common interview mistakes
- Treating a successful
docker run --rm --network shop nicolaka/netshoot bash -c "dig +short db; nc -vz db 5432; curl -sv http://api:8080/health"as proof and skippingrepeat from the failing app container with the same network and compare DNS result, port test and application status separately. - Debugging only localhost, or reporting “DNS is down” from a TCP timeout without an explicit name lookup result
- Optimizing DNS Debug without accepting that a disposable toolbox is fast and clean; permanent observability is necessary to correlate intermittent multi-host failures over time.
Likely interviewer follow-ups
- Why does
docker run --rm --network shop nicolaka/netshoot bash -c "dig +short db; nc -vz db 5432; curl -sv http://api:8080/health"address DNS Debug here rather than through application code? - How would you distinguish healthy curl from the failure “debugging only localhost, or reporting “DNS is down” from a TCP timeout without an explicit name lookup result” using
repeat from the failing app container with the same network and compare DNS result, port test and application status separately? - When would this trade-off-“A disposable toolbox is fast and clean; permanent observability is necessary to correlate intermittent multi-host failures over time”-justify a different netshoot design?
docker run --rm --network shop nicolaka/netshoot bash -c "dig +short db; nc -vz db 5432; curl -sv http://api:8080/health"-and one proof-repeat from the failing app container with the same network and compare DNS result, port test and application status separately. Then name the boundary: debugging only localhost, or reporting “DNS is down” from a TCP timeout without an explicit name lookup result.Knowledge check
Put it into practice
Practice related interview Q&A
Apply Debugging Network Issues (nslookup, dig, curl, netshoot container) with generative AI interview Q&A and hands-on practice.