Skip to content

Instantly share code, notes, and snippets.

@artem-shestakov
Last active March 24, 2023 11:13
Show Gist options
  • Save artem-shestakov/f7c914ed3f9c991ca6ff3a9eda3c8d02 to your computer and use it in GitHub Desktop.
Save artem-shestakov/f7c914ed3f9c991ca6ff3a9eda3c8d02 to your computer and use it in GitHub Desktop.
Check ports/connections inside containers
#!/bin/bash
containers=`docker ps -q`
for container in $containers; do
c_pid=`docker inspect -f '{{ .State.Pid }}' $container`
c_name=`docker inspect -f '{{ .Name }}' $container`
echo "--- CONTAINER: $c_name ---"
nsenter -t ${c_pid} -n netstat -anp
echo -e "\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment