Skip to content

Commit

Permalink
fix tool
Browse files Browse the repository at this point in the history
  • Loading branch information
chris468 committed Jun 27, 2024
1 parent b454ffa commit 54e5fda
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions dotfiles/dot_local/bin/capture-container-network
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ tmpdir=$(mktemp -d)
docker build -t tcpdump - <<EOF
FROM ubuntu
RUN apt-get update && apt-get install -y tcpdump
ENTRYPOINT ["tcpdump", "-i", "any"]
VOLUME ["/data"]
ENTRYPOINT ["tcpdump", "-U", "-i", "any", "-A", "-w", "/data/packets.pcap"]
EOF

docker run -d --rm --net container:$1 -v $tmpdir:/data tcpdump -i any -A -w /data/packets.pcap
docker run -d --rm --net container:$1 --name tcpdump -v $tmpdir:/data tcpdump

tail -c+0 -f $tmpdir/packets.pcap | wireshark -i -
while [ ! -e $tmpdir/packets.pcap ] ; do
sleep 1
done

echo "$tmpdir/packets.pcap"
tail -c+0 -f "$tmpdir/packets.pcap" | wireshark -k -i -

docker stop tcpdump

0 comments on commit 54e5fda

Please sign in to comment.