@@ -127,6 +127,8 @@ check_until_filter_support() {
127127SIX_MONTHS=4320h
128128TWO_WEEKS=336h
129129ONE_WEEK=168h
130+ FIVE_DAYS=120h
131+ THREE_DAYS=72h
130132
131133# Define Macros For Temp files
132134IMAGES=$( mktemp)
234236echo
235237
236238# #########################################################
237- # 7. Other prune operations (skip image prune if exclusions present)
239+ # 7. Remove images where TAG is <none>
240+ # #########################################################
241+ echo " Scanning for images where TAG is <none> and older than 5 days ..."
242+
243+ if [ " ${USE_UNTIL_FILTER:- false} " = true ]; then
244+ _imglist=$( $CLI images --filter " until=$FIVE_DAYS " --format ' {{.Repository}} {{.Tag}} {{.ID}}' )
245+ else
246+ echo " Skipping age filter for <none>-tag images (unsupported 'until' filter)."
247+ _imglist=$( $CLI images --format ' {{.Repository}} {{.Tag}} {{.ID}}' )
248+ fi
249+
250+ none_tag_images=$( printf ' %s\n' " $_imglist " | awk ' $2=="<none>" {print $3}' | sort -u)
251+
252+ if [ -n " $none_tag_images " ]; then
253+ count=$( printf ' %s\n' " $none_tag_images " | wc -l | tr -d ' ' )
254+ echo " Found $count image(s) with <none> tag older than 5 days."
255+
256+ if [ " $ACTION " = " delete" ]; then
257+ echo " Removing images with <none> tag..."
258+ # shellcheck disable=SC2086
259+ run rmi -f $none_tag_images
260+ else
261+ echo " CHECK mode: would remove images with <none> tag."
262+ for iid in $none_tag_images ; do
263+ printf ' Would run: %s rmi -f %s %s\n' " $CLI " " $iid " " $EXTRA_ARGS "
264+ done
265+ fi
266+ else
267+ echo " No <none> tag images older than 5 days found."
268+ fi
269+ echo
270+
271+ # #########################################################
272+ # 8. Other prune operations (skip image prune if exclusions present)
238273# #########################################################
239274echo " Pruning builder cache older than $TWO_WEEKS ..."
240275if [ " $USE_UNTIL_FILTER " = true ]; then
@@ -263,6 +298,6 @@ run network prune -f
263298echo
264299
265300# #########################################################
266- # 8 . Summary
301+ # 9 . Summary
267302# #########################################################
268303echo " Housekeeping finished in $ACTION mode."
0 commit comments