Update docs/command output for volume pruning

In previous versions of the Docker API, `system prune --volumes` and `volume prune`
would remove all dangling volumes. With API v1.42, this was changed so that only
anonymous volumes would be removed unless the all filter was specified.

Some of the docs were updated in #4218, however, there were a couple of places
left that didn't make the anonymous vs named volumes distinction clear.

This replaces #4079, which was bitrotted by #4218. See also #4028.

Closes #4079.

Signed-off-by: Ed Morley <501702+edmorley@users.noreply.github.com>
This commit is contained in:
Ed Morley 2023-08-12 14:19:17 +01:00
parent 9bd5ec504a
commit 6e2e92d774
No known key found for this signature in database
GPG Key ID: 2ED9B3624CA3B874
6 changed files with 9 additions and 9 deletions

View File

@ -48,7 +48,7 @@ func newPruneCommand(dockerCli command.Cli) *cobra.Command {
flags := cmd.Flags() flags := cmd.Flags()
flags.BoolVarP(&options.force, "force", "f", false, "Do not prompt for confirmation") flags.BoolVarP(&options.force, "force", "f", false, "Do not prompt for confirmation")
flags.BoolVarP(&options.all, "all", "a", false, "Remove all unused images not just dangling ones") flags.BoolVarP(&options.all, "all", "a", false, "Remove all unused images not just dangling ones")
flags.BoolVar(&options.pruneVolumes, "volumes", false, "Prune volumes") flags.BoolVar(&options.pruneVolumes, "volumes", false, "Prune anonymous volumes")
flags.Var(&options.filter, "filter", `Provide filter values (e.g. "label=<key>=<value>")`) flags.Var(&options.filter, "filter", `Provide filter values (e.g. "label=<key>=<value>")`)
// "filter" flag is available in 1.28 (docker 17.04) and up // "filter" flag is available in 1.28 (docker 17.04) and up
flags.SetAnnotation("filter", "version", []string{"1.28"}) flags.SetAnnotation("filter", "version", []string{"1.28"})
@ -114,7 +114,7 @@ func confirmationMessage(dockerCli command.Cli, options pruneOptions) string {
"all networks not used by at least one container", "all networks not used by at least one container",
} }
if options.pruneVolumes { if options.pruneVolumes {
warnings = append(warnings, "all volumes not used by at least one container") warnings = append(warnings, "all anonymous volumes not used by at least one container")
} }
if options.all { if options.all {
warnings = append(warnings, "all images without at least one container associated to them") warnings = append(warnings, "all images without at least one container associated to them")

View File

@ -27,7 +27,7 @@ func NewPruneCommand(dockerCli command.Cli) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "prune [OPTIONS]", Use: "prune [OPTIONS]",
Short: "Remove all unused local volumes", Short: "Remove unused local volumes",
Args: cli.NoArgs, Args: cli.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
spaceReclaimed, output, err := runPrune(dockerCli, options) spaceReclaimed, output, err := runPrune(dockerCli, options)

View File

@ -101,7 +101,7 @@ read the [`dockerd`](dockerd.md) reference page.
| [volume create](volume_create.md) | Creates a new volume where containers can consume and store data | | [volume create](volume_create.md) | Creates a new volume where containers can consume and store data |
| [volume inspect](volume_inspect.md) | Display information about a volume | | [volume inspect](volume_inspect.md) | Display information about a volume |
| [volume ls](volume_ls.md) | Lists all the volumes Docker knows about | | [volume ls](volume_ls.md) | Lists all the volumes Docker knows about |
| [volume prune](volume_prune.md) | Remove all unused local volumes | | [volume prune](volume_prune.md) | Remove unused local volumes |
| [volume rm](volume_rm.md) | Remove one or more volumes | | [volume rm](volume_rm.md) | Remove one or more volumes |
### Swarm node commands ### Swarm node commands

View File

@ -10,7 +10,7 @@ Remove unused data
| `-a`, `--all` | | | Remove all unused images not just dangling ones | | `-a`, `--all` | | | Remove all unused images not just dangling ones |
| [`--filter`](#filter) | `filter` | | Provide filter values (e.g. `label=<key>=<value>`) | | [`--filter`](#filter) | `filter` | | Provide filter values (e.g. `label=<key>=<value>`) |
| `-f`, `--force` | | | Do not prompt for confirmation | | `-f`, `--force` | | | Do not prompt for confirmation |
| `--volumes` | | | Prune volumes | | `--volumes` | | | Prune anonymous volumes |
<!---MARKER_GEN_END--> <!---MARKER_GEN_END-->
@ -50,7 +50,7 @@ Total reclaimed space: 1.84kB
By default, volumes are not removed to prevent important data from being By default, volumes are not removed to prevent important data from being
deleted if there is currently no container using the volume. Use the `--volumes` deleted if there is currently no container using the volume. Use the `--volumes`
flag when running the command to prune volumes as well: flag when running the command to prune anonymous volumes as well:
```console ```console
$ docker system prune -a --volumes $ docker system prune -a --volumes
@ -58,7 +58,7 @@ $ docker system prune -a --volumes
WARNING! This will remove: WARNING! This will remove:
- all stopped containers - all stopped containers
- all networks not used by at least one container - all networks not used by at least one container
- all volumes not used by at least one container - all anonymous volumes not used by at least one container
- all images without at least one container associated to them - all images without at least one container associated to them
- all build cache - all build cache
Are you sure you want to continue? [y/N] y Are you sure you want to continue? [y/N] y

View File

@ -10,7 +10,7 @@ Manage volumes
| [`create`](volume_create.md) | Create a volume | | [`create`](volume_create.md) | Create a volume |
| [`inspect`](volume_inspect.md) | Display detailed information on one or more volumes | | [`inspect`](volume_inspect.md) | Display detailed information on one or more volumes |
| [`ls`](volume_ls.md) | List volumes | | [`ls`](volume_ls.md) | List volumes |
| [`prune`](volume_prune.md) | Remove all unused local volumes | | [`prune`](volume_prune.md) | Remove unused local volumes |
| [`rm`](volume_rm.md) | Remove one or more volumes | | [`rm`](volume_rm.md) | Remove one or more volumes |
| [`update`](volume_update.md) | Update a volume (cluster volumes only) | | [`update`](volume_update.md) | Update a volume (cluster volumes only) |

View File

@ -1,7 +1,7 @@
# volume prune # volume prune
<!---MARKER_GEN_START--> <!---MARKER_GEN_START-->
Remove all unused local volumes Remove unused local volumes
### Options ### Options