Skip to content

Instantly share code, notes, and snippets.

@jherax
Last active May 30, 2020 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jherax/7b3ddc74e1d752006401dc34cee0003f to your computer and use it in GitHub Desktop.
Save jherax/7b3ddc74e1d752006401dc34cee0003f to your computer and use it in GitHub Desktop.
Load docker and put it in the shell
# in your .zshrc
function docker_clean() {
containers=$(docker ps -a -q -f status=exited)
# echo $containers
if [ "" != "$containers" ] ; then
docker rm -v $containers
fi
}
# in your .zshrc
function docker_start() {
machine_status=$(docker-machine status)
# echo $machine_status
# If the machine is already running, it skips the start command
# and will fix the environment variables of the current shell.
if [ "Stopped" = "$machine_status" ] ; then
docker-machine start default
fi
eval "$(docker-machine env default)"
}
# in your zsh profile
function docker_start() {
machine_status=$(docker-machine status)
# echo $machine_status
# If the machine is already running, it skips the start command
# and will fix the environment variables of the current shell.
if [ "Stopped" == $machine_status ]
then
docker-machine start default
fi
eval "$(docker-machine env default)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment