opencontainers / opencontainers/runc

Enhancement: Add option to delete all stopped containers in `runc delete`

Open
#4,933 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
13.5k
Forks
2.3k
Avg merge
2d 8h
Merged PRs (30d)
30

Description

Description:
Currently, runc delete can only remove a single container by its ID. It would be convenient to have an option to delete all stopped containers at once, without manually iterating over container IDs.

Use case / scenario:
In environments where runc is used directly for batch container management, or in scenarios like runc#4853

In such high-volume situations, cleaning up stopped containers manually or one by one is not only cumbersome but also may exacerbate resource contention (e.g., DBus delays, cgroup lock contention).

Proposed solution:

Add a new flag to runc delete, e.g., --all-stopped, which deletes all containers in the stopped state.

The command should skip running containers and only clean up metadata and cgroups of stopped containers.

Reuse existing internal delete logic to ensure consistency.

Example usage:

Delete all stopped containers

runc delete --all-stopped or
runc delete -a

Benefits:

Simplifies cleanup of stopped containers in batch or high-volume environments

Avoids manually scripting runc delete for multiple containers

Keeps CLI consistent with the single-container delete semantics

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the runc delete command and its existing internal delete logic, then trace how container states and IDs are enumerated. Done means a new --all-stopped or -a option removes metadata and cgroups only for stopped containers while leaving running containers unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.