Created
September 4, 2015 13:56
-
-
Save guywithnose/221b3d05329cca73c04d to your computer and use it in GitHub Desktop.
Append IP Address to docker ps output
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 | |
PS="$(docker ps)" | |
echo "${PS}" | head -1 | sed 's/$/\t\t\t\t\tIP/' | |
LINES="$(echo "$PS" | sed '1d')" | |
IFS=$(echo -e '\n') | |
for LINE in $LINES | |
do | |
ID=$(echo "${LINE}" | awk '{print $1}') | |
IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' "${ID}") | |
echo -e "${LINE}\t${IP}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment