Interview's MateDocker
Interview's Mate

Docker

Compose · Networking · Security · Ops

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Docker topics
Lesson 77/ 160
04. Docker Networking

Debugging Network Issues (nslookup, dig, curl, netshoot container)

Debug DNS and connectivity with dig, curl, and the netshoot toolbox container.

IntermediateDNS Debug · curl3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

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

Loading interactive 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.

Concrete DNS Debug setup

docker run --rm --network shop nicolaka/netshoot bash -c "dig +short db; nc -vz db 5432; curl -sv http://api:8080/health"

Key takeaway: Prove curl with 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.

Deliberate failure test

Exercise this failure safely: debugging only localhost, or reporting “DNS is down” from a TCP timeout without an explicit name lookup result.

Key takeaway: A disposable toolbox is fast and clean; permanent observability is necessary to correlate intermittent multi-host failures over time.

How it works, step by step

Step 1 of 4
Design

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

Use the affected container’s namespace so diagnostics observe the same DNS, routes and iptables decisions as the failing process.
Key numbers at this step
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 separately in 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

Explicit DNS Debug
Best for: Debug DNS and connectivity with dig, curl, and the netshoot toolbox container, with a reviewed runbook.

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.

Ambient default
Best for: Short-lived curl experiments with low blast radius.

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.

Managed netshoot
Best for: Teams that centralize netshoot policy across many workloads.

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 skipping repeat 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?
Interview tip: Give one concrete operation-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

Loading quiz

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.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
Automatic SSL/TLS & Dynamic Routing with Traefik
Next topic
Packet Inspection & Traffic Troubleshooting inside Containers