Skip to content

Instantly share code, notes, and snippets.

@fluxrad
Created May 18, 2016 13:58
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 fluxrad/d7587187e7db02a906b599c30f7659dc to your computer and use it in GitHub Desktop.
Save fluxrad/d7587187e7db02a906b599c30f7659dc to your computer and use it in GitHub Desktop.
A script to check if the Docker daemon is up. If not, reboot after three failed docker ps commands.
#!/bin/bash
SLEEP_SECONDS=600
while true; do
for i in `seq 1 3`; do
timeout 5 docker ps -q && break || echo "Docker daemon is not running. Rebooting"
if [[ $i -eq 3 ]]; then
reboot
fi
done
echo "Docker is up. Sleeping ${SLEEP_SECONDS} seconds"
sleep ${SLEEP_SECONDS}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment