Skip to content

Instantly share code, notes, and snippets.

@mikaelz
Forked from Zaffy/docker-etc-hosts
Created July 26, 2018 10:00
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 mikaelz/57463609cc5735bdc598a2f60dc53cd3 to your computer and use it in GitHub Desktop.
Save mikaelz/57463609cc5735bdc598a2f60dc53cd3 to your computer and use it in GitHub Desktop.
Docker: print ips and containers' names suitable for use in /etc/hosts
for i in `docker ps -a -q | awk '{print $1}'`; do echo $(docker inspect --format="{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" $i) $(docker ps | grep $i | awk '{print $NF}') ; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment