Last active
April 10, 2017 03:07
-
-
Save samundra/0a8f1ab6bedd4c795a2ff37266d2b9b9 to your computer and use it in GitHub Desktop.
List the active running docker containers ip
This file contains 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 | |
set -e | |
## List all actively running docker container ip | |
## | |
## USAGE: | |
## chmod +x docker-network.sh | |
## ./docker-network.sh | |
## | |
## OUTPUT: 172.19.0.5 - my_container_2 | |
## 172.19.0.4 - my_container_4 | |
## 172.19.0.3 - my_container_1 | |
## 172.19.0.2 - my_container_3 | |
## ... | |
DCONTAINERS=`docker ps --format='{{.Names}}'` | |
for container in ${DCONTAINERS[@]}; do | |
echo `docker inspect ${container}| grep "IPAddress\": \"[0-9].*\""|\ | |
sed 's/,//g' | \cut -f2 -d ":" | sed 's/\"//g'` - ${container}| sort -n | |
done; |
❤️
🎉
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍