check docker status in every seconds instead of sleep

This commit is contained in:
2024-02-09 08:38:55 +00:00
parent 48699a0498
commit 3b2458c519

View File

@@ -197,8 +197,19 @@ check_running() {
DOCKERD_STATUS=$($SUDO_CMD systemctl status docker | grep running | wc -l)
if [ "$DOCKERD_STATUS" == "0" ]; then
$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
echo "Docker daemon not running, please check and execute again the install script";
exit;