Skip to content

Instantly share code, notes, and snippets.

@speelbarrow
Created May 17, 2023 18:50
Show Gist options
  • Save speelbarrow/43e685b6b167d862b83702b42bd0d749 to your computer and use it in GitHub Desktop.
Save speelbarrow/43e685b6b167d862b83702b42bd0d749 to your computer and use it in GitHub Desktop.
Wrapper for 'docker' command on macOS that starts Docker Desktop if it's not already running so that you don't have to
function docker {
if ! command docker info &> /dev/null; then
open -a /Applications/Docker.app
echo -n "Waiting for Docker to start ."
local slept=0
until [ $slept -eq 15 ] || command docker info &> /dev/null; do
sleep 1
((slept++))
echo -n " ."
done
if [ $slept -eq 15 ]; then
echo " Docker failed to start"
return 1
fi
fi
command docker $@
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment