Skip to content

Instantly share code, notes, and snippets.

@jliu70
Created May 23, 2017 00:56
Show Gist options
  • Select an option

  • Save jliu70/64ce846eb9fd80140aad9a4328d090e5 to your computer and use it in GitHub Desktop.

Select an option

Save jliu70/64ce846eb9fd80140aad9a4328d090e5 to your computer and use it in GitHub Desktop.
List docker network details
#!/bin/bash
JQYES=""
while getopts ":jh" opt; do
case $opt in
j)
JQYES=1;;
h)
echo
echo "$0 "
echo
echo " -j parse output with jq"
echo " -h display this help message"
echo
exit
;;
\?)
echo "Invalid option: -$OPTARG"
break
;;
*)
echo "Invalid option: -$OPTARG"
break
;;
esac
done
if [ $JQYES ];
then
JQINST=$(which jq)
if [ $JQINST ];
then
for i in $(docker network ls -q); do docker network inspect $i | jq -r '.[].Name, .[].IPAM.Config'; done
else
for i in $(docker network ls -q); do docker network inspect $i |egrep "Name|Subnet|Gateway"; done
exit
fi
else
for i in $(docker network ls -q); do docker network inspect $i |egrep "Name|Subnet|Gateway"; done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment