Skip to content

Prune the volumes nobody named, and the rest only when asked - #2176

Closed
MayCXC wants to merge 1 commit into
apple:mainfrom
MayCXC:volume-prune-anonymous
Closed

Prune the volumes nobody named, and the rest only when asked#2176
MayCXC wants to merge 1 commit into
apple:mainfrom
MayCXC:volume-prune-anonymous

Conversation

@MayCXC

@MayCXC MayCXC commented Aug 27, 2026

Copy link
Copy Markdown

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

Closes #2169.

A volume mounted without a name is created because a container mounts it, and is of no use to anyone once nothing mounts it. A volume someone named is theirs, and one that nothing mounts yet is still theirs to mount later, so removing it because nothing mounts it takes away something they asked for and did not ask to lose.

Prune takes the anonymous ones, and the named ones only when asked for all of them. That is what pruning images does here already: dangling by default, and every unused image when asked for all of them. Volumes carry the label that tells them apart from the moment one is created without a name, so nothing new is recorded to do it.

Pruning containers and networks needs none of this. Every network is named when it is made and every stopped container was asked for by name, so neither has a kind that nobody asked for.

Marked breaking because container volume prune with no flags removes strictly less than it did: an unused named volume now survives until --all.

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

The serial suite asks for all of them where it means an unused volume it named, and a new case covers the split itself: an anonymous volume goes, the named one beside it stays, and asking for all takes that one too.

Integration suite: 397 passed. Unit suite: 772 passed. make fmt, make check clean.

A volume mounted without a name is created because a container mounts it,
and is of no use to anyone once nothing mounts it. A volume someone named
is theirs, and one that nothing mounts yet is still theirs to mount later,
so removing it because nothing mounts it takes away something they asked
for and did not ask to lose.

Prune takes the anonymous ones, and the named ones only when asked for all
of them. That is what pruning images does here already: dangling by
default, and every unused image when asked for all of them. Volumes carry
the label that tells them apart from the moment one is created without a
name, so nothing new is recorded to do it.

Pruning containers and networks needs none of this. Every network is named
when it is made and every stopped container was asked for by name, so
neither has a kind that nobody asked for.

The serial suite asks for all of them where it means an unused volume it
named, and a new case covers the split itself: an anonymous volume goes,
the named one beside it stays, and asking for all takes that one too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Request]: volume prune should take the anonymous volumes by default and named ones only with --all

2 participants