Skip to content

Instantly share code, notes, and snippets.

@remysaissy
Created January 5, 2016 15:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remysaissy/6a000870ff63300b8567 to your computer and use it in GitHub Desktop.
Save remysaissy/6a000870ff63300b8567 to your computer and use it in GitHub Desktop.
Shell function to let a MacOSX user load a docker-machine environment and update OSX routes to access docker0 IPs directly
# Load the docker-machine environment and update the route to let MacOSX access containers IPs.
denv() {
eval $(docker-machine env $1)
SUBNET=$(docker network inspect $(docker network ls | grep bridge | awk '{ print $1; }') | grep Subnet | awk '{ gsub(/"/, "", $2); print $2; }')
sudo route -n delete $SUBNET
sudo route -n add $SUBNET $(docker-machine ip $1)
echo "[docker-machine] $1 env loaded with subnet $SUBNET."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment