Skip to content

Instantly share code, notes, and snippets.

@inadarei
Last active March 4, 2017 15:58
Show Gist options
  • Save inadarei/c7a211553440216982ad to your computer and use it in GitHub Desktop.
Save inadarei/c7a211553440216982ad to your computer and use it in GitHub Desktop.
Bash Profile Script for Guaranteed Docker Machine Activation
# Make sure that ur #docker host is active & ready to go, in every shell, no matter what:
export DOCKER_MACHINE_ACTIVE="your-docker-machine-name"
export DOCKER_MACHINE_ACTIVE_STATUS=`docker-machine ls | grep -i "$DOCKER_MACHINE_ACTIVE" | grep "Running" | awk '{ print $2}'`
if [ "$DOCKER_MACHINE_ACTIVE_STATUS" != "*" ]; then
if [ "$DOCKER_MACHINE_ACTIVE_STATUS" != "-" ]; then
echo "Docker machine $DOCKER_MACHINE_ACTIVE not running. Starting…"
docker-machine start $DOCKER_MACHINE_ACTIVE
sleep 3s
eval "$(docker-machine env $DOCKER_MACHINE_ACTIVE)"
else
# echo "Docker machine $DOCKER_MACHINE_ACTIVE not active. Activating…"
eval "$(docker-machine env $DOCKER_MACHINE_ACTIVE)"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment