Skip to content

Instantly share code, notes, and snippets.

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 schmunk42/64a92256ccbc28faf999 to your computer and use it in GitHub Desktop.
Save schmunk42/64a92256ccbc28faf999 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
list=( $(docker-machine ls | grep Running | awk '{ print $1 }') )
for i in "${list[@]}"; do
ip=$(docker-machine ip $i)
#remove line matching ip
sudo sed -i '' '/'$ip'/d' /etc/hosts
#insert ip/host on last line
sudo sed -i -e '$a\
'"$ip"' '"$i"'' /etc/hosts
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment