Podman how remove all exited containers if there are many
Asked Answered
D

2

8

On a server running containers with Podman I just realised, there are many containers with "Exited" status and wanted to remove all of them in one go.

How can I do it with Podman?

Danner answered 14/5, 2021 at 3:49 Comment(0)
D
6

After searching for some time I found a quick and easy one liner to get my exited containers cleaned.

One option is:

podman rm -f $(podman ps -a -f "status=exited" -q)

The second option is:

podman ps -f status=exited --format "{{.ID}}" | xargs podman rm -f

A big thanks to dannotdaniel for the second option. This saved me at least an hour. :)

Danner answered 14/5, 2021 at 3:49 Comment(0)
C
18

According to the official documentation there is a specific command for just that purpose:

Remove all stopped containers from local storage:

podman container prune
Clardy answered 18/5, 2021 at 11:11 Comment(0)
D
6

After searching for some time I found a quick and easy one liner to get my exited containers cleaned.

One option is:

podman rm -f $(podman ps -a -f "status=exited" -q)

The second option is:

podman ps -f status=exited --format "{{.ID}}" | xargs podman rm -f

A big thanks to dannotdaniel for the second option. This saved me at least an hour. :)

Danner answered 14/5, 2021 at 3:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.