Created
January 24, 2026 19:55
-
-
Save brandonhimpfen/d954e2200bda1296d9a7d8e5e1c61167 to your computer and use it in GitHub Desktop.
Tiny Docker “debug container” one-liners for troubleshooting networks, DNS, HTTP, and containers (docker run -it --rm ...).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Docker Debug Container One-Liners | |
| # Use these to quickly troubleshoot networking, DNS, HTTP, TLS, ports, etc. | |
| # without installing tools on your host machine. | |
| # --------------------------------------------------------------------------- | |
| # 1) Fast interactive shell in a tiny container | |
| # --------------------------------------------------------------------------- | |
| docker run -it --rm alpine:latest sh | |
| # If you want common networking tools (curl, dig, ping, etc.) | |
| docker run -it --rm nicolaka/netshoot bash | |
| # --------------------------------------------------------------------------- | |
| # 2) Curl from inside a container (great for service checks) | |
| # --------------------------------------------------------------------------- | |
| docker run -it --rm curlimages/curl:latest https://example.com | |
| # Curl with verbose TLS output | |
| docker run -it --rm curlimages/curl:latest -v https://example.com | |
| # --------------------------------------------------------------------------- | |
| # 3) DNS checks (dig / nslookup) | |
| # --------------------------------------------------------------------------- | |
| docker run -it --rm nicolaka/netshoot dig example.com | |
| docker run -it --rm nicolaka/netshoot nslookup example.com | |
| # --------------------------------------------------------------------------- | |
| # 4) Ping / traceroute | |
| # --------------------------------------------------------------------------- | |
| docker run -it --rm nicolaka/netshoot ping -c 3 8.8.8.8 | |
| docker run -it --rm nicolaka/netshoot traceroute example.com | |
| # --------------------------------------------------------------------------- | |
| # 5) Test TCP ports quickly (nc) | |
| # --------------------------------------------------------------------------- | |
| docker run -it --rm nicolaka/netshoot nc -vz example.com 443 | |
| docker run -it --rm nicolaka/netshoot nc -vz 127.0.0.1 5432 | |
| # --------------------------------------------------------------------------- | |
| # 6) Attach debug tools to the same network namespace as another container | |
| # (super useful when you need to debug container-to-container networking) | |
| # --------------------------------------------------------------------------- | |
| # Replace <container_name> with the running container you're debugging | |
| docker run -it --rm --network container:<container_name> nicolaka/netshoot bash | |
| # Example: | |
| # docker run -it --rm --network container:my-api nicolaka/netshoot bash | |
| # --------------------------------------------------------------------------- | |
| # 7) Join a Docker network (debug service discovery) | |
| # --------------------------------------------------------------------------- | |
| # Replace <network_name> with your compose network | |
| docker run -it --rm --network <network_name> nicolaka/netshoot bash | |
| # Example: | |
| # docker run -it --rm --network myproject_default nicolaka/netshoot bash | |
| # --------------------------------------------------------------------------- | |
| # 8) Use host networking (Linux only; handy for localhost checks) | |
| # --------------------------------------------------------------------------- | |
| docker run -it --rm --network host nicolaka/netshoot bash | |
| # --------------------------------------------------------------------------- | |
| # 9) Mount current folder and debug files in a container | |
| # --------------------------------------------------------------------------- | |
| docker run -it --rm -v "$PWD":/work -w /work alpine:latest sh | |
| # With tools: | |
| docker run -it --rm -v "$PWD":/work -w /work nicolaka/netshoot bash | |
| # --------------------------------------------------------------------------- | |
| # 10) Inspect HTTP endpoints from within a target Docker network | |
| # --------------------------------------------------------------------------- | |
| docker run -it --rm --network <network_name> curlimages/curl:latest http://my-service:8080/health | |
| # --------------------------------------------------------------------------- | |
| # 11) Inspect SSL certs / TLS handshakes (openssl) | |
| # --------------------------------------------------------------------------- | |
| docker run -it --rm nicolaka/netshoot openssl s_client -connect example.com:443 -servername example.com | |
| # --------------------------------------------------------------------------- | |
| # 12) Debug a Kubernetes cluster or cloud network from a container | |
| # --------------------------------------------------------------------------- | |
| # netshoot has many helpful tools: | |
| # curl, dig, nslookup, ip, ss, netstat, traceroute, tcpdump, etc. | |
| docker run -it --rm --privileged --net=host nicolaka/netshoot bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment