C.W.K.
Stream
Lesson 03 of 03 · published

Network Debugging — netshoot, dig, curl, nslookup

~14 min · debug, networking

Level 0Container Curious
0 XP0/36 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

The container can't reach the database — now what?

Service-to-service network problems are the second-most-common debugging category. Don't install diagnostic tools into your application image. Use a dedicated debug image — nicolaka/netshoot is the canonical choice and ships with curl, dig, nslookup, tcpdump, mtr, and friends.

Code

Probe a network from inside·bash
# Drop a debug container onto the same network as the broken service
docker run --rm -it --network app-net nicolaka/netshoot

# Inside:
nslookup api          # does DNS resolve?
curl -v http://api:8000/health   # does HTTP work?
ping -c 2 db          # are we even on the same network?
tcpdump -i any 'port 5432'  # what's actually crossing the wire?

External links

Exercise

Use netshoot to diagnose a multi-container compose stack: from a netshoot container on the same network, verify (a) DNS resolves all services by name, (b) ports are reachable, (c) curl -v returns expected responses. Capture the four most useful commands.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.