Last active
March 4, 2017 15:58
-
-
Save inadarei/c7a211553440216982ad to your computer and use it in GitHub Desktop.
Bash Profile Script for Guaranteed Docker Machine Activation
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
# 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