Skip to content

[22.06 backport] Volume prune: only prune anonymous volumes by default#44259

Merged
cpuguy83 merged 1 commit intomoby:22.06from
thaJeztah:22.06_backport_volume_unnamed_label
Oct 6, 2022
Merged

[22.06 backport] Volume prune: only prune anonymous volumes by default#44259
cpuguy83 merged 1 commit intomoby:22.06from
thaJeztah:22.06_backport_volume_unnamed_label

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

This adds a new filter argument to the volume prune endpoint "all". When this is not set, or it is a false-y value, then only anonymous volumes are considered for pruning.

When all is set to a truth-y value, you get the old behavior.

This is an API change, but I think one that is what most people would want.

(cherry picked from commit 618f26c)

- What I did

- How I did it

- How to verify it

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

This adds a new filter argument to the volume prune endpoint "all".
When this is not set, or it is a false-y value, then only anonymous
volumes are considered for pruning.

When `all` is set to a truth-y value, you get the old behavior.

This is an API change, but I think one that is what most people would
want.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 618f26c)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@cpuguy83 cpuguy83 merged commit 6442025 into moby:22.06 Oct 6, 2022
@thaJeztah thaJeztah deleted the 22.06_backport_volume_unnamed_label branch October 6, 2022 00:36
@chrisbecke
Copy link
Copy Markdown

So what's the behaviour of docker system prune --volumes intended to be?

@jcmcken
Copy link
Copy Markdown

jcmcken commented Feb 7, 2023

It seems like this was included in Docker 23 and broke docker system prune. Users of docker volumes prune now need to include this filter as well. This is awfully confusing behavior. Especially since the --help on docker volumes prune makes zero mention of it

@robertjgtoth
Copy link
Copy Markdown

robertjgtoth commented Apr 5, 2023

Is there backwards compatible syntax that can be used to prune volumes across versions (keeping the old behavior)?

We have many docker nodes deployed, which often have a mix of different CLI versions (upgrades are not always feasible immediately for a variety of reasons I won't get into, including disparate OS). Introducing this change not only breaks existing scripts we have to prune data volumes, but is also non-backwards-compatible such that any nodes running slightly out-of-date daemons fail hard with Invalid filter 'all' when introducing this new flag. This seems to me like the developers have no qualms breaking what used to be a pretty stable API with very little documentation or accommodations for compatibility between versions.

Any suggestions on how to prune all volumes with the same command both before and after this change would be great.

archlinux-github pushed a commit to archlinux/infrastructure that referenced this pull request Nov 25, 2023
"docker system prune --volumes" does no longer prune named volumes in
Docker 23.0[1][2], so use "docker volume prune --all"[3] for pruning
named volumes.

[1] docker/cli#4028
[2] moby/moby#44259
[3] docker/cli#4229
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants