Skip to content

Commit 4d6d58c

Browse files
committed
docker: gate image cleanup behind DOCKER_PRUNE=yes (default off)
docker_cli_prepare() called docker_cleanup_old_images unconditionally, which enumerates 'docker images' and rmi's old armbian tags. Fine on a single-daemon workstation; broken on hosts where several build framework invocations share one dockerd — the usual setup when multiple self-hosted GH Actions runners live on the same machine. Two concurrent invocations race: runner A's cleanup fires 'docker rmi <id>' on a tag runner B just committed between 'Successfully built <sha>' and dockerd writing the imagedb digest file. B's build then aborts with: Successfully built ed6bcbe445e6 failed to get digest sha256:ed6bcbe445e6…: open /var/lib/docker/image/overlay2/imagedb/content/sha256/…: no such file or directory Make the cleanup opt-in via DOCKER_PRUNE=yes. Default-off keeps shared-daemon setups safe out of the box; single-host users who want automatic disk reclaim flip the flag and either accept the race risk or serialise their builds. No behaviour change for users who add DOCKER_PRUNE=yes — same codepath runs. Only the default changes.
1 parent 22f3925 commit 4d6d58c

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

lib/functions/host/docker.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,27 @@ function docker_cli_prepare() {
155155
fi
156156

157157
#############################################################################################################
158-
# Cleanup old Docker images to free disk space
159-
docker_cleanup_old_images
158+
# Optionally clean up old Docker images to free disk space. Off by
159+
# default — set DOCKER_PRUNE=yes to opt in.
160+
#
161+
# The cleanup enumerates `docker images` and calls `docker rmi` on
162+
# "old" ones. On hosts where several build invocations share one
163+
# dockerd (the usual setup when multiple self-hosted GH Actions
164+
# runners live on the same machine) two concurrent invocations
165+
# race: runner A's cleanup can rmi an image runner B just
166+
# committed between `Successfully built <sha>` and the daemon
167+
# writing the imagedb digest file, surfacing as:
168+
# failed to get digest sha256:…: open …/imagedb/content/sha256/…:
169+
# no such file or directory
170+
# which aborts runner B's build. Default-off keeps shared-daemon
171+
# setups safe; single-host users who want automatic reclaim set
172+
# DOCKER_PRUNE=yes and either accept the race risk or run builds
173+
# serially.
174+
if [[ "${DOCKER_PRUNE:-no}" == "yes" ]]; then
175+
docker_cleanup_old_images
176+
else
177+
display_alert "Skipping Docker image cleanup" "set DOCKER_PRUNE=yes to enable" "debug"
178+
fi
160179

161180
#############################################################################################################
162181
# Detect some docker info; use cached.

0 commit comments

Comments
 (0)