-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a wrapper for docker that waits for daemon
See linked gitlab issue for more info: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27300
- Loading branch information
1 parent
afe7a0c
commit 96baa25
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,21 @@ | ||
#!/bin/sh | ||
|
||
# A wrapper for docker to check that wait for docker daemon to spin up. See: | ||
# https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27300 | ||
|
||
wait_for_dockerd() { | ||
END=$(expr $(date +%s) + 30) # Wait for 30s at most. | ||
while ! /usr/bin/docker info >/dev/null 2>&1; do | ||
if [ $(date +%s) -ge "$END" ]; then | ||
return 1 | ||
fi | ||
sleep 1 | ||
done | ||
} | ||
|
||
if ! wait_for_dockerd; then | ||
echo "Failed to connect Docker daemon!" >&2 | ||
exit 1 | ||
fi | ||
|
||
exec /usr/bin/docker "$@" |