Skip to content

Commit a3971a3

Browse files
committed
containers: prune dangling images
Previously, upgrading Podman containers with the same tag left behind dangling images, causing overlay storage to grow and fill disk space. This change ensures dangling images are cleaned up using podman image prune. The command is run without -a, so only unreferenced images are removed. This provides safe cleanup while preventing unnecessary overlay growth. It's worth noting that when upgrading a container image using system wide upgrade and reboot, then it's normal for one dangling image to be left on the system after reboot. This is because the prune is done at shutdown. When rebooting after upgrade the running container is still valid and after the reboot the old container is replaced and left dangling until the next reboot. There should be no case where more than two image (one dangling) exists for a particular container. Fixes #1098 Signed-off-by: Richard Alpe <[email protected]>
1 parent fa7c743 commit a3971a3

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

board/common/rootfs/usr/sbin/container

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ delete()
302302
log "$name: calling podman rm -vif ..."
303303
podman rm -vif "$name" >/dev/null 2>&1
304304
[ -n "$quiet" ] || log "Container $name has been removed."
305+
306+
cnt=$(podman image prune -f | wc -l)
307+
log "Pruned $cnt image(s)"
305308
}
306309

307310
waitfor()

doc/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ All notable changes to the project are documented in this file.
1414

1515

1616
### Fixes
17+
- containers: prune dangling images to reclaim disk space (#1098)
18+
1719
[v25.06.0][] - 2025-07-01
1820
-------------------------
1921

0 commit comments

Comments
 (0)