Created
May 23, 2017 00:56
-
-
Save jliu70/64ce846eb9fd80140aad9a4328d090e5 to your computer and use it in GitHub Desktop.
List docker network details
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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