Skip to content

Instantly share code, notes, and snippets.

@slavahatnuke
Created June 2, 2016 21:07
Show Gist options
  • Save slavahatnuke/8f5c6908cf024a7271ff203d6a07f873 to your computer and use it in GitHub Desktop.
Save slavahatnuke/8f5c6908cf024a7271ff203d6a07f873 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
update-docker-host(){
# clear existing docker.local entry from /etc/hosts
sudo sed -i '' '/[[:space:]]docker\.local$/d' /etc/hosts
# get ip of running machine
export DOCKER_IP="$(echo ${DOCKER_HOST} | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')"
# update /etc/hosts with docker machine ip
[[ -n $DOCKER_IP ]] && sudo /bin/bash -c "echo \"${DOCKER_IP} docker.local\" >> /etc/hosts"
}
update-docker-host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment