Skip to content

Instantly share code, notes, and snippets.

@whit3rabbit
Last active May 6, 2022 16:25
Show Gist options
  • Select an option

  • Save whit3rabbit/dfb739a2872e082e30e1d80ea1488ff2 to your computer and use it in GitHub Desktop.

Select an option

Save whit3rabbit/dfb739a2872e082e30e1d80ea1488ff2 to your computer and use it in GitHub Desktop.
Docker Swarm Packet Capture
#!/bin/bash
echo "[+] Getting docker swarm ingress network ID"
INGRESS=`sudo docker network ls | grep ingress | cut -b -10`
echo "[+] Ingress: $INGRESS"
echo "[+] Running netshoot container with tcpdump"
read -p "[?] Filename for packet capture: " OUTPUT_FILE
echo "[+] Output pcap is at: $PWD/$OUTPUT_FILE"
sudo docker run -it --rm \
-v /var/run/docker/netns:/var/run/docker/netns \
-v $PWD:/root/ \
--privileged=true nicolaka/netshoot \
nsenter --net=/var/run/docker/netns/1-$INGRESS \
tcpdump -i any -w /root/$OUTPUT_FILE -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment