check docker status in every seconds instead of sleep

This commit is contained in:
2024-02-09 12:00:41 +00:00
parent adc93a18b3
commit 2299c902ca

View File

@@ -197,8 +197,19 @@ check_running() {
DOCKERD_STATUS=$($SUDO_CMD systemctl status docker | grep running | wc -l) DOCKERD_STATUS=$($SUDO_CMD systemctl status docker | grep running | wc -l)
if [ "$DOCKERD_STATUS" == "0" ]; then if [ "$DOCKERD_STATUS" == "0" ]; then
$SUDO_CMD systemctl start docker $SUDO_CMD systemctl start docker
sleep 5;
DOCKERD_STATUS=$($SUDO_CMD systemctl status docker | grep running | wc -l) # wait for docker start, check in every seconds, run for max. 60 sec
WAIT_COUNT=0;
while [ "$DOCKERD_STATUS" == "0" ]; do
sleep 1;
WAIT_COUNT=$((WAIT_COUNT+1))
DOCKERD_STATUS=$($SUDO_CMD systemctl status docker | grep running | wc -l)
if [ $WAIT_COUNT -gt 60 ]; then
break; # docker hasn't started in 60 seconds
fi;
done;
if [ "$DOCKERD_STATUS" == "0" ]; then if [ "$DOCKERD_STATUS" == "0" ]; then
echo "Docker daemon not running, please check and execute again the install script"; echo "Docker daemon not running, please check and execute again the install script";
exit; exit;