Quick Start Guide

This guide will walk you through the most basic use cases for Netshoot in both Docker and Kubernetes to get you started in minutes.

Docker: Interactive Session

The simplest way to use Netshoot is to run it as a standalone, interactive container. This is useful for testing general network connectivity from your Docker host.

  1. Run the Netshoot container:

    The command below starts an interactive (-it) shell in a Netshoot container and automatically removes it (--rm) when you exit.

    docker run -it --rm nicolaka/netshoot
  2. Use the tools:

    You will be greeted by the Netshoot welcome message and dropped into a zsh prompt. From here, you can use any of the included tools. Let's test DNS and external connectivity.

    # Inside the netshoot container
    ping google.com
    PING google.com (142.250.187.238): 56 data bytes
    64 bytes from 142.250.187.238: seq=0 ttl=118 time=10.381 ms
    64 bytes from 142.250.187.238: seq=1 ttl=118 time=10.235 ms
    ...
  3. Exit the container:

    Simply type exit or press Ctrl+D.

Kubernetes: Ephemeral Pod

In Kubernetes, you can quickly spin up a temporary Netshoot pod for troubleshooting cluster networking.

  1. Run a temporary Netshoot pod:

    The command below creates a pod named tmp-shell, gives you an interactive TTY (-i --tty), and configures the pod to be deleted (--rm) as soon as you exit the shell.

    kubectl run tmp-shell --rm -i --tty --image nicolaka/netshoot
  2. Use the tools:

    Once the pod is running, you'll be at the zsh prompt inside the container. You can now test cluster-internal DNS resolution and connectivity.

    # Inside the netshoot pod
    # See if the Kubernetes API server is resolvable
    drill kubernetes.default.svc.cluster.local
    ;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 50921
    ;; flags: qr aa rd ra ; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 
    ;; QUESTION SECTION:
    ;; kubernetes.default.svc.cluster.local. IN A
    
    ;; ANSWER SECTION:
    kubernetes.default.svc.cluster.local. 30 IN A 10.96.0.1
    
    ;; AUTHORITY SECTION:
    
    ;; ADDITIONAL SECTION:
    
    ;; Query time: 0 msec
    ;; SERVER: 10.96.0.10:53
    ;; WHEN: ...
    ;; MSG SIZE  rcvd: 66
  3. Exit and clean up:

    Type exit or press Ctrl+D. The pod will be automatically terminated and deleted.