Skip to content

Instantly share code, notes, and snippets.

@frontdevops
Created January 9, 2016 20:25
Show Gist options
  • Save frontdevops/d988750600eaff6b005c to your computer and use it in GitHub Desktop.
Save frontdevops/d988750600eaff6b005c to your computer and use it in GitHub Desktop.
# add this file in your .bashrc file:
# source docker.sh
dockerip() {
docker inspect --format '{{ .NetworkSettings.IPAddress }}' "$@"
}
dockerips() {
for dock in $(docker ps | tail -n +2 | cut -d" " -f1)
do
local dock_ip=$(dockerip $dock)
[[ -n "$dock_ip" ]] && regex="s/$dock\s\{3\}/${dock:0:3} $dock_ip/g;$regex"
done
docker ps -a | sed -e "$regex"
}
#EOF#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment