From 56f7bd075956af7c36a85e2abe706232a3b682aa Mon Sep 17 00:00:00 2001 From: Austin Vazquez Date: Thu, 4 Sep 2025 17:26:07 -0500 Subject: [PATCH 1/2] Set `ReservedSpace` field in preparation of `KeepStorage` deprecation This change updates the builder prune command to send the `ReservedSpace` parameter in preparation of `KeepStorage` deprecation in API v1.52. Signed-off-by: Austin Vazquez (cherry picked from commit 7d85d8fbeac5b0ab3d09e6a5317bc4c9eaff9516) Signed-off-by: Sebastiaan van Stijn --- cli/command/builder/prune.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cli/command/builder/prune.go b/cli/command/builder/prune.go index 9eef43216429..e57534cbfb19 100644 --- a/cli/command/builder/prune.go +++ b/cli/command/builder/prune.go @@ -85,9 +85,12 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) } report, err := dockerCli.Client().BuildCachePrune(ctx, build.CachePruneOptions{ - All: options.all, - KeepStorage: options.keepStorage.Value(), // FIXME(thaJeztah): rewrite to use new options; see https://github.com/moby/moby/pull/48720 - Filters: pruneFilters, + All: options.all, + // TODO(austinvazquez): remove when updated to use github.com/moby/moby/client@v0.1.0 + // See https://github.com/moby/moby/pull/50772 for more details. + KeepStorage: options.keepStorage.Value(), + ReservedSpace: options.keepStorage.Value(), + Filters: pruneFilters, }) if err != nil { return 0, "", err From 09fcf8e3dd7082cdc67c484a725cf4e7593b23e7 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 24 Sep 2025 12:10:57 +0200 Subject: [PATCH 2/2] cli/command: NewDockerCli: don't depend on DockerCli.Apply The Apply method was added when CLI options for constructing the CLI were rewritten into functional options in [cli@7f207f3]. There was no mention in the pull request of this method specifically, and this may have been related to work being done elsewhere on compose-on-kubernetes or the compose-cli plugin that may have needed options to modify the CLI config after it was already initialized. We should try to remove functions that mutate the CLI configuration after initialization if possible (and likely remove the `Apply` method); currently this function is used in docker compose, but as part of a hack that can probably be avoided. [cli@7f207f3]: https://github.com/docker/cli/commit/7f207f3f957ed3f5129aeb22bef2a429c14caf22 Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 133279fb0d4adea30d27d27eb8789b79405fc82b) Signed-off-by: Sebastiaan van Stijn --- cli/command/cli.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cli/command/cli.go b/cli/command/cli.go index b657ff313d49..c62d6be3c44b 100644 --- a/cli/command/cli.go +++ b/cli/command/cli.go @@ -603,8 +603,10 @@ func NewDockerCli(ops ...CLIOption) (*DockerCli, error) { ops = append(defaultOps, ops...) cli := &DockerCli{baseCtx: context.Background()} - if err := cli.Apply(ops...); err != nil { - return nil, err + for _, op := range ops { + if err := op(cli); err != nil { + return nil, err + } } return cli, nil }