Skip to content

Instantly share code, notes, and snippets.

@guywithnose
Created September 4, 2015 13:56
Show Gist options
  • Save guywithnose/221b3d05329cca73c04d to your computer and use it in GitHub Desktop.
Save guywithnose/221b3d05329cca73c04d to your computer and use it in GitHub Desktop.
Append IP Address to docker ps output
#!/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