Interview Prep/Networking/Command-Line Tools & Diagnostics

How do you debug a network issue in a container without network tools in the image?

AdvancedConceptCommand-Line Tools & Diagnostics
Answer

Use a debug container or enter the network namespace from the host.

kubectl debug -it pod/web-7d9 --image=nicolaka/netshoot --target=web
docker inspect -f '{{.State.Pid}}' web          # then:
sudo nsenter -t <PID> -n ss -tulpn
sudo nsenter -t <PID> -n tcpdump -i eth0 -nn

The --target flag shares the process namespace so you see the app's sockets, and you do not have to rebuild or modify the image.

All Networking questions Roadmap: Networking for DevOps

More on Command-Line Tools & Diagnostics