pruneFn calls the Volume Prune API for use in "docker system prune", and returns the amount of space reclaimed and a detailed output string.
(ctx context.Context, dockerCli command.Cli, options pruner.PruneOptions)
| 120 | // pruneFn calls the Volume Prune API for use in "docker system prune", |
| 121 | // and returns the amount of space reclaimed and a detailed output string. |
| 122 | func pruneFn(ctx context.Context, dockerCli command.Cli, options pruner.PruneOptions) (uint64, string, error) { |
| 123 | // TODO version this once "until" filter is supported for volumes |
| 124 | // Ideally, this check wasn't done on the CLI because the list of |
| 125 | // filters that is supported by the daemon may evolve over time. |
| 126 | if _, ok := options.Filter.Value()["until"]; ok { |
| 127 | return 0, "", errors.New(`ERROR: The "until" filter is not supported with "--volumes"`) |
| 128 | } |
| 129 | if !options.Confirmed { |
| 130 | // Dry-run: perform validation and produce confirmation before pruning. |
| 131 | confirmMsg := "all anonymous volumes not used by at least one container" |
| 132 | return 0, confirmMsg, cancelledErr{errors.New("volume prune has been cancelled")} |
| 133 | } |
| 134 | return runPrune(ctx, dockerCli, pruneOptions{ |
| 135 | force: true, |
| 136 | filter: options.Filter, |
| 137 | }) |
| 138 | } |