7

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?

BMitch
  • 231,797
  • 42
  • 475
  • 450
NIK
  • 1,089
  • 13
  • 22

2 Answers2

15

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

Remove all stopped containers from local storage:

podman container prune
5

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. :)

NIK
  • 1,089
  • 13
  • 22