Skip to content

Instantly share code, notes, and snippets.

@alexbilbie
Created February 10, 2016 09:52
Show Gist options
  • Save alexbilbie/e9ac80498942b93a3c80 to your computer and use it in GitHub Desktop.
Save alexbilbie/e9ac80498942b93a3c80 to your computer and use it in GitHub Desktop.
DOCKER_ENV="$HOME/.dockerenv"
DOCKER_MACHINE_NAME="default"
# Docker environment helpers
denv() {
eval "$(cat $DOCKER_ENV)"
}
dstart() {
docker-machine start $DOCKER_MACHINE_NAME
docker-machine env $DOCKER_MACHINE_NAME > $DOCKER_ENV
denv
}
dstop() {
docker-machine stop $DOCKER_MACHINE_NAME
rm "$HOME/.dockerenv"
}
# Docker executables
dshell() {
if [ -z "$@" ]; then
echo "An image name must be specified"
return 1;
fi
docker run --rm -it "$@" sh
}
# Initialize Docker environment if one exists
if [[ -f $DOCKER_ENV ]]; then
denv
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment