Skip to content

Instantly share code, notes, and snippets.

@skatsuta
Last active January 9, 2016 08:15
Show Gist options
  • Save skatsuta/bcfe85a3550f6e3f8e2f to your computer and use it in GitHub Desktop.
Save skatsuta/bcfe85a3550f6e3f8e2f to your computer and use it in GitHub Desktop.
.envrc for setting environment variables of Docker Machine
local machine=dev
local state=`docker-machine ls | grep $machine | awk '{ print $4 }'`
# Start machine if not running
if [[ "$state" != "Running" ]]; then
echo "Machine \"$machine\" is not running. Starting..."
docker-machine start $machine
docker-compose up -d
fi
# Set env vars for the machine
if [[ $DOCKER_MACHINE_NAME != $machine ]]; then
eval "`docker-machine env $machine`"
fi
export DOCKER_IP=`docker-machine ip $machine`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment