Skip to content

Commit

Permalink
add retry when docker daemon not started (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
iberryful authored and ib-steffen committed Nov 30, 2018
1 parent c6de838 commit 780c872
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions src/job/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,48 @@ mkdir -p /data/tmp
mkdir -p /data/repo
mkdir -p ~/.ssh

if [ ! -e /var/run/docker.sock ]; then
echo "Docker Daemon Config"
cat /etc/docker/daemon.json
echo ""

echo "Waiting for docker daemon to start up"

function startDocker() {
# Start docker daemon
nohup dockerd-entrypoint.sh --storage-driver $INFRABOX_JOB_STORAGE_DRIVER --data-root /data/docker &> /tmp/dockerd.log &

sleep 5
# Wait until daemon is ready
COUNTER=0
until docker version &> /dev/null; do
let COUNTER=COUNTER+1
sleep 1

if [ $COUNTER -gt 60 ]; then
echo "Docker daemon not started" > '/dev/termination-log'
cat /tmp/dockerd.log >> /dev/termination-log
exit 1
return 1
fi
done
return 0
}


if [ ! -e /var/run/docker.sock ]; then
echo "Docker Daemon Config"
cat /etc/docker/daemon.json
echo ""

echo "Waiting for docker daemon to start up"
CNT=0
while true; do
if [ $CNT -gt 3 ]; then
echo "Docker daemon not started" > '/dev/termination-log'
cat /tmp/dockerd.log >> /dev/termination-log
exit 1
fi
let CNT=CNT+1

if startDocker ; then
echo "Docker daemon stared."
break
eles
echo "Docker daemon not stared, retry"
sleep 60
fi
done
else
echo "Using host docker daemon socket"
fi
Expand Down

0 comments on commit 780c872

Please sign in to comment.