Skip to content

Instantly share code, notes, and snippets.

@jgraglia
Created March 17, 2016 13:05
Show Gist options
  • Save jgraglia/e7d871bf26e12d99b446 to your computer and use it in GitHub Desktop.
Save jgraglia/e7d871bf26e12d99b446 to your computer and use it in GitHub Desktop.
Docker : launch wireshark on a container
#https://github.com/crccheck/docker-tcpdump
#docker ps format help https://docs.docker.com/engine/reference/commandline/ps/#format
# IPT : https://github.com/ruyadorno/ipt
function dshark {
if [ $# == 0 ]; then
CONTAINER=`docker ps --format='table {{.ID}} | {{.Names}} | {{.Command}}' | ipt | cut -d '|' -f 1`
if [ "$$CONTAINER" == "" ]; then
echo "Missing docker container: $CONTAINER"
return 1
fi
else
CONTAINER=$1
fi
echo "Will launch Wireshark capture on container $CONTAINER"
docker ps --filter "id=$CONTAINER"
docker run --rm --net=container:$CONTAINER crccheck/tcpdump -i any --immediate-mode -w - | wireshark -k -i -
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment