-
Notifications
You must be signed in to change notification settings - Fork 534
Docker-in-docker: Add retries to the docker-init script until docker daemon starts #637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
samruddhikhandale
merged 2 commits into
main
from
samruddhikhandale/dnd-retry-docker-init
Aug 7, 2023
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| # Optional: Import test library | ||
| source dev-container-features-test-lib | ||
|
|
||
| # Definition specific tests | ||
| check "docker-buildx" docker buildx version | ||
| check "docker-ps" docker ps | ||
|
|
||
| sleep 5s | ||
|
|
||
| # Stop docker | ||
| pkill dockerd | ||
| pkill containerd | ||
|
|
||
| sleep 5s | ||
|
|
||
| set +e | ||
| docker_ok_code="$(docker info > /dev/null 2>&1; echo $?)" | ||
| set -e | ||
|
|
||
| check "docker-not-running" bash -c "[[ ${docker_ok_code} == 1 ]]" | ||
|
|
||
| # Testing retry logic | ||
| ./test-scripts/docker-test-init.sh | ||
|
|
||
| check "docker-started-after-retries" docker ps | ||
|
|
||
| # Report result | ||
| reportResults |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.