Created
May 17, 2023 18:50
-
-
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
This file contains hidden or 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
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