-
-
Save junereycasuga/623aab7e36d1a0257c5e059ae0220566 to your computer and use it in GitHub Desktop.
List the actively running docker container 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 the actively running docker container ip | |
## Usage chmod +x docker-network.sh | |
## ./docker-network.sh | |
## | |
## Output: container_1 - 172.17.0.2 | |
## container-2 - 172.17.0.3 | |
## container-2 - 172.17.0.4 | |
## ... | |
DCONTAINERS=`docker ps --format='{{.Names}}'` | |
for d in ${DCONTAINERS[@]}; do | |
echo ${d} - `docker inspect ${d}| grep "IPAddress\": \"[0-9].*\""|\ | |
sed 's/,//g' - | \cut -f2 -d ":" | sed 's/\"//g'` | sort -n | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment