feat(cli): add dv prune to remove stale containers - #39
Merged
Merged
Conversation
Problem: dv agents pile up. Each stopped container keeps its writable layer (often 1-3GB), and nothing removes them, so a machine ends up with dozens of agents nobody has run in weeks. Removing them by hand with plain docker skips dv's config cleanup and hooks, and it can't tell an abandoned agent from one holding work that was never pushed. Solution: dv prune lists dv-owned containers (com.dv.owner=dv or recorded in config, any image) that are stopped and last ran longer ago than --older-than (default 14d; 2w and 36h also work). Last run is State.FinishedAt, or Created for a container that never started. - Without --yes it only lists candidates, oldest first. - With --yes each candidate is started briefly and its git checkouts (the effective workdir and each plugin) are checked for uncommitted changes, stashes and commits on no remote. Containers with work, or that can't be checked, are kept and reported; the rest are removed through dv remove, so config cleanup and hooks run. - The selected agent, the default container and --keep names are never pruned. Suitable for a scheduled `dv prune --yes` (systemd timer or cron).
ZogStriP
approved these changes
Oct 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem: dv agents pile up. Each stopped container keeps its writable layer (often 1-3GB), and nothing removes them, so a machine ends up with dozens of agents nobody has run in weeks. Removing them by hand with plain docker skips dv's config cleanup and hooks, and it can't tell an abandoned agent from one holding work that was never pushed.
Solution: dv prune lists dv-owned containers (com.dv.owner=dv or recorded in config, any image) that are stopped and last ran longer ago than --older-than (default 14d; 2w and 36h also work). Last run is State.FinishedAt, or Created for a container that never started.
Suitable for a scheduled
dv prune --yes(systemd timer or cron).