Skip to content

Instantly share code, notes, and snippets.

@protosam
Created May 16, 2023 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save protosam/27d15417a92633109a7b25177de594d7 to your computer and use it in GitHub Desktop.
Save protosam/27d15417a92633109a7b25177de594d7 to your computer and use it in GitHub Desktop.
#!/bin/bash
# detect mac os
if ! uname | grep -i -q darwin; then
echo "ERROR: Only Mac OS is supported."
exit 1
fi
# kill docker desktop
DOCKER_DESKTOP_PID=$(ps aux | grep '/Applications/Docker\.app/Contents/MacOS/Docker$' | awk '{print $2}')
if [ ! -z "${DOCKER_DESKTOP_PID}" ]; then
kill "${DOCKER_DESKTOP_PID}"
echo "Waiting for Docker Desktop to close."
while ps aux | grep 'com\.docker|Docker\.app'; do
sleep 1
done
fi
# start docker desktop
if open /Applications/Docker.app; then
echo "Waiting for Docker Desktop to start."
while ! docker ps >/dev/null 2>&1; do
sleep 1
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment