Skip to content

setup_container_runtime: Fix image pruning#2583

Open
djgalloway wants to merge 1 commit into
mainfrom
76605
Open

setup_container_runtime: Fix image pruning#2583
djgalloway wants to merge 1 commit into
mainfrom
76605

Conversation

@djgalloway
Copy link
Copy Markdown
Contributor

podman system prune --force can still exit 0 even if there are images still in use by external containers. e.g.,

+ podman system prune --force
Deleted Images
63ce0076aa6cdd5544433330d81d0a116b3cfcace3d3ca7aabcf953d97ee819d
2234e3448b78b20836a83c3559ba45ec0d3713786c9ce8ccaadd0ae728b6c3b5
Total reclaimed space: 1.607GB

real	0m1.948s
user	0m0.536s
sys	0m1.061s
+ podman image prune --filter=until=168h --all --force
Error: 2 errors occurred:
	* image used by b0c2fcd16e3423046b704d626ee30f1e9d455efb844640aa83f61d0f2bf7b426: image is in use by a container: consider listing external containers and force-removing image
	* image used by fe06141e65c607edd79df847d793116c00b9749cea2bb5b1b247cfca1c72e9d9: image is in use by a container: consider listing external containers and force-removing image

real	0m19.330s
user	0m1.280s
sys	0m10.139s
Build step 'Execute shell' marked build as failure

Since this script is already pretty destructive, just add --external unconditionally.

@djgalloway djgalloway requested a review from zmc May 15, 2026 18:37
`podman system prune --force` can still exit 0 even if there are
images still in use by external containers.  e.g.,

```
+ podman system prune --force
Deleted Images
63ce0076aa6cdd5544433330d81d0a116b3cfcace3d3ca7aabcf953d97ee819d
2234e3448b78b20836a83c3559ba45ec0d3713786c9ce8ccaadd0ae728b6c3b5
Total reclaimed space: 1.607GB

real	0m1.948s
user	0m0.536s
sys	0m1.061s
+ podman image prune --filter=until=168h --all --force
Error: 2 errors occurred:
	* image used by b0c2fcd16e3423046b704d626ee30f1e9d455efb844640aa83f61d0f2bf7b426: image is in use by a container: consider listing external containers and force-removing image
	* image used by fe06141e65c607edd79df847d793116c00b9749cea2bb5b1b247cfca1c72e9d9: image is in use by a container: consider listing external containers and force-removing image

real	0m19.330s
user	0m1.280s
sys	0m10.139s
Build step 'Execute shell' marked build as failure
```

Since this script is already pretty destructive, just add --external unconditionally.

Fixes: #2583

Signed-off-by: David Galloway <david.galloway@ibm.com>
Copy link
Copy Markdown
Member

@zmc zmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable, but let's note that it will reduce the effectiveness of the build/image cache. I wonder if it could be useful to monitor podman's storage footprint on the builders to see trends over time.

I'd consider the podman behavior to be a bug, fwiw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants