Packing any application with a tiny/bare minimal base image sounds like an awesome/cool/intelligent idea, until things break and there are no tools inside the container to debug the problem at hand.
This repo/docker image solves this problem by providing a robust image equipped with a wide array of tools needed to debug the majority of issues in production environments.
This image also includes a very small web application for testing/debugging purposes.
# Run and attach to the network namespace of the container to debug
docker run --name swiss-army-knife --net=container:${CONTAINER_ID_TO_DEBUG} -itd ranchersupport/swiss-army-knife-v2
# Exec into the tools container
docker exec -it swiss-army-knife bash
# Show off your ninja skill!
tcpdump -i eth0 -vvv -nn -s0 -SS -XX# Find the target container's PID
TARGET_CONTAINER_ID=<TARGET_CONTAINER_ID>
TARGET_CONTAINER_PID=$(crictl inspect --output go-template --template '{{.info.pid}}' $TARGET_CONTAINER_ID)
# Run swiss-army-knife and attach to the target container's network namespace
ctr run --rm --privileged \
--mount type=bind,src=/proc/${TARGET_CONTAINER_PID}/ns/net,dst=/proc/self/ns/net,options=rbind:ro \
ranchersupport/swiss-army-knife-v2 swiss-army-knife bashThe swiss-army-knife image includes the following tools:
tcpdumptraceroutetelnetnetcat-openbsdping(viaiputils)dig(viabind-utils)nslookup(viabind-utils)ifconfig(vianet-tools)ethtooliptablesipsetiproute2conntrack-toolssocat
curlwgettreevim-smalllessjq
kmodpsmisc(e.g.,killall)opensslca-certificatestcpdump
kubectlthe current stable version is included at the time of image builds
-
Debugging Network Issues:
- Use tools like
tcpdump,dig, andnslookupto debug DNS and network traffic.
- Use tools like
-
Testing Web Applications:
- Use
curl,wget, ortelnetto test service availability.
- Use
-
Kubernetes Troubleshooting:
- Multiple versions of
kubectlare included for compatibility with different Kubernetes clusters.
- Multiple versions of
-
System Debugging:
- Utilize tools like
ps,ifconfig, andiptablesto debug issues at the OS level.
- Utilize tools like
This container is your one-stop shop for debugging and testing in production environments. It eliminates the need to install extra tools during critical times, ensuring you are always prepared.
Happy debugging! 🚀