Created
January 5, 2016 15:12
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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