diff options
author | Samruddhi Khandale <skhandale@microsoft.com> | 2023-08-08 01:59:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-08 01:59:58 +0300 |
commit | bbb24d10d417452ef23a8c506fd0e2b141b71f15 (patch) | |
tree | 11bd7cb31f8d26b64ee56916d920bbb4d6915769 /test/docker-in-docker/test-scripts/docker-test-init.sh | |
parent | 29859aff280dc187d6f508900f8600ebd04c56b7 (diff) |
Docker-in-docker: Add retries to the docker-init script until docker daemon starts (#637)feature_docker-in-docker_2.3.0
* Docker-in-docker: Add retries until docker daemon starts
* address comments
Diffstat (limited to 'test/docker-in-docker/test-scripts/docker-test-init.sh')
-rw-r--r-- | test/docker-in-docker/test-scripts/docker-test-init.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/docker-in-docker/test-scripts/docker-test-init.sh b/test/docker-in-docker/test-scripts/docker-test-init.sh new file mode 100644 index 0000000..b213fb4 --- /dev/null +++ b/test/docker-in-docker/test-scripts/docker-test-init.sh @@ -0,0 +1,26 @@ +#!/bin/sh +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- + +retry_count=0 +docker_ok="false" + +until [ "${docker_ok}" = "true" ] || [ "${retry_count}" -eq "5" ]; +do + if [ "${retry_count}" -eq "3" ]; then + echo "Starting docker after 3 retries..." + /usr/local/share/docker-init.sh + fi + + set +e + docker info > /dev/null 2>&1 && docker_ok="true" + + if [ "${docker_ok}" != "true" ]; then + echo "(*) Failed to start docker, retrying in 5s... Retry count: ${retry_count}" + retry_count=`expr $retry_count + 1` + sleep 1s + fi + set -e +done
\ No newline at end of file |