Skip to content

Instantly share code, notes, and snippets.

@samundra
Last active April 10, 2017 03:07
Show Gist options
  • Save samundra/0a8f1ab6bedd4c795a2ff37266d2b9b9 to your computer and use it in GitHub Desktop.
Save samundra/0a8f1ab6bedd4c795a2ff37266d2b9b9 to your computer and use it in GitHub Desktop.
List the active running docker containers ip
#!/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;
@zzzet
Copy link

zzzet commented Jan 16, 2017

👍

@junereycasuga
Copy link

❤️

@isudnop
Copy link

isudnop commented Jan 16, 2017

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment