From 323fbc485e5902fbbab97ad86cb5d4f90f956e39 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 26 Aug 2025 23:47:17 +0200 Subject: [PATCH] cli/command/image: remove special handling for plugin errors on pull This special handling was added in [moby@9b6dcc8], and later updated in [moby@c127d96], but it fully depended on string-matching, which is brittle. Testing the original ticket that lead to this handling, it looks like the string matching no longer works, and the daemon error is returned as-is: With graphdrivers: docker pull tiborvass/no-remove Using default tag: latest Error response from daemon: Encountered remote "application/vnd.docker.plugin.v0+json"(unknown) when fetching With containerd snapshotters enabled: docker pull tiborvass/no-remove Using default tag: latest latest: Pulling from tiborvass/no-remove cf635291f7c9: Download complete failed to unpack image on snapshotter overlayfs: mismatched image rootfs and manifest layers The error-message for containerd can probably be improved, but as the special handling in the CLI no longer works, we can remove it. [moby@9b6dcc8]: https://github.com/moby/moby/commit/9b6dcc8b9d1366d3da3c8f60f89de1a36b087b88 [moby@c127d96]: https://github.com/moby/moby/commit/c127d9614f5b30bd73861877f8540a63e7d869e9 Signed-off-by: Sebastiaan van Stijn --- cli/command/image/pull.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/cli/command/image/pull.go b/cli/command/image/pull.go index 16616861bd..e30a5f9482 100644 --- a/cli/command/image/pull.go +++ b/cli/command/image/pull.go @@ -2,15 +2,14 @@ package image import ( "context" + "errors" "fmt" - "strings" "github.com/distribution/reference" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/trust" - "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -78,15 +77,13 @@ func runPull(ctx context.Context, dockerCLI command.Cli, opts pullOptions) error // Check if reference has a digest _, isCanonical := distributionRef.(reference.Canonical) if !opts.untrusted && !isCanonical { - err = trustedPull(ctx, dockerCLI, imgRefAndAuth, opts) - } else { - err = imagePullPrivileged(ctx, dockerCLI, imgRefAndAuth, opts) - } - if err != nil { - if strings.Contains(err.Error(), "when fetching 'plugin'") { - return errors.New(err.Error() + " - Use `docker plugin install`") + if err := trustedPull(ctx, dockerCLI, imgRefAndAuth, opts); err != nil { + return err + } + } else { + if err := imagePullPrivileged(ctx, dockerCLI, imgRefAndAuth, opts); err != nil { + return err } - return err } _, _ = fmt.Fprintln(dockerCLI.Out(), imgRefAndAuth.Reference().String()) return nil