Skip to content

Commit c0802dd

Browse files
authored
Merge pull request #1090 from crazy-max/docker-install-retry
docker(install): retry macOS archive installs on transient apt mirror failures
2 parents 2f1916f + c3d1cd7 commit c0802dd

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

src/docker/assets.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,27 @@ provision:
250250
export DEBIAN_FRONTEND=noninteractive
251251
if [ "{{srcType}}" == "archive" ]; then
252252
{
253-
curl -fsSL https://get.docker.com | sh -s -- --channel {{srcArchiveChannel}} --version {{srcArchiveVersion}}
253+
getDockerScript=$(mktemp)
254+
curl --retry 3 --retry-all-errors --retry-delay 5 -fsSL -o "$getDockerScript" https://get.docker.com
255+
256+
attempt=1
257+
max_attempts=3
258+
until [ "$attempt" -gt "$max_attempts" ]; do
259+
echo "Docker install attempt $attempt/$max_attempts"
260+
if sh "$getDockerScript" --channel {{srcArchiveChannel}} --version {{srcArchiveVersion}}; then
261+
break
262+
fi
263+
if [ "$attempt" -eq "$max_attempts" ]; then
264+
echo >&2 "Docker install failed after $max_attempts attempts"
265+
exit 1
266+
fi
267+
echo >&2 "Docker install attempt $attempt failed, retrying after $((attempt * 30))s"
268+
rm -rf /var/lib/apt/lists/partial/* || true
269+
apt-get clean || true
270+
sleep $((attempt * 30))
271+
attempt=$((attempt + 1))
272+
done
273+
254274
sed -i 's|^ExecStart=.*|ExecStart=/usr/bin/dockerd -H fd://{{#if localTCPPort}} -H tcp://0.0.0.0:2375{{/if}} --containerd=/run/containerd/containerd.sock|' /usr/lib/systemd/system/docker.service
255275
systemctl daemon-reload
256276
systemctl restart docker

0 commit comments

Comments
 (0)