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.
More on Command-Line Tools & Diagnostics
How do you check if a remote port is open?BeginnerHow do you list listening ports and the processes that own them?BeginnerWhat does `ping` tell you and what does it not?BeginnerHow does traceroute work and how do you read the output?BeginnerWhat is mtr and why is it better than traceroute?IntermediateHow do you query DNS with dig and read the answer?Beginner