Skip to content

Instantly share code, notes, and snippets.

@khornberg
Last active September 9, 2015 21:15
Show Gist options
  • Save khornberg/1b9dae44d65f126dd01f to your computer and use it in GitHub Desktop.
Save khornberg/1b9dae44d65f126dd01f to your computer and use it in GitHub Desktop.
#!/bin/bash
# Redefined the docker command to connect if the shell has not already
# done so. This speeds up the shell start up.
docker() {
if [ "$DOCKER_HOST" = "" ]; then
# Setup docker
if [ -x /usr/local/bin/docker-machine ]; then
# suppress standard out
eval "docker-machine env default --shell=bash >/dev/null"
S=$?
# If an error occurs try staring the VM
if [ $S -ne 0 ]; then
echo "Starting the VM"
eval "docker-machine start default"
eval "$(docker-machine env default --shell=bash)"
else
eval "$(docker-machine env default --shell=bash)"
fi
fi
/usr/local/bin/docker $@ # do the command passed
else
/usr/local/bin/docker $@
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment