Skip to content
Latchkey

podman rm: Remove Containers in CI

podman rm removes one or more containers, freeing the name and any anonymous volumes if asked.

Cleaning up containers keeps a runner from accumulating cruft and avoids name clashes on reused runners. -f stops and removes in one step.

What it does

podman rm deletes stopped containers by name or ID. With -f it stops a running container first; with -a it targets all containers. --volumes also removes anonymous volumes created with the container.

Common usage

Terminal
podman rm db
podman rm -f app
podman rm -a -f
podman rm --volumes db

Options

FlagWhat it does
-f, --forceStop and remove a running container
-a, --allRemove all containers
-v, --volumesAlso remove anonymous volumes of the container
-i, --ignoreIgnore errors for containers that do not exist
--time <n>Seconds to wait before killing on force

In CI

Prefer --rm on podman run so containers self-clean. When that is not possible, use podman rm -f --ignore in a cleanup step so a missing container does not fail the job. On reused runners, a leftover container causes the next run name conflict.

Common errors in CI

"Error: cannot remove container ... as it is running, stop or use -f" means the container is still up; add -f. "Error: no container with name or ID ... found" is cleared with --ignore in teardown. A name conflict on the next run ("the container name ... is already in use") means a prior container was never removed; rm it first or use --replace on run.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →