Skip to content

Instantly share code, notes, and snippets.

@andmarios
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andmarios/45073a53c408091e6dce to your computer and use it in GitHub Desktop.
Save andmarios/45073a53c408091e6dce to your computer and use it in GitHub Desktop.
Replace container IDs with container IPs for `docker ps`
#!/usr/bin/env bash
docker ps | while read DLINE
do
CONTAINER="$(echo $DLINE | grep -Eo "^[a-f0-9]{12,12}")"
[[ ! -z "$CONTAINER" ]] && CIP="$(docker inspect $CONTAINER | grep IPAd | cut -d \" -f 4)"
echo "$DLINE" | sed -e "s/[a-f0-9]\{12,12\}/$CIP/"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment