From d31c241ea56ce433eda80ddbd2eaffca7183f780 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 11 Oct 2024 14:47:13 +0200 Subject: [PATCH] PushImage: remove misleading error about --platform without containerd Without containerd store enabled, we were discarding underlying errors, and instead informing the user that `--platform` is not suported; docker pull --quiet --platform=linux/riscv64 alpine:latest docker image push --platform=linux/amd64 alpine:latest Error response from daemon: graphdriver backed image store doesn't support multiplatform images However, that's not the case; platform filtering works, but if the image is not the right platform, the push fails (which is the same as would happen with the containerd image store enabled). docker image push --platform=linux/amd64 alpine:latest Error response from daemon: image with reference docker.io/library/alpine:latest was found but does not match the specified platform: wanted linux/amd64, actual: linux/riscv64 When specifying the platform and that platform matches, it finds the image, and the push continue; docker image push --platform=linux/riscv64 alpine:latest The push refers to repository [docker.io/library/alpine] 3fd4750fd687: Layer already exists ... (The above example obviously fails because I don't have permissions to push official images). Signed-off-by: Sebastiaan van Stijn --- daemon/images/image_push.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/daemon/images/image_push.go b/daemon/images/image_push.go index 6a841f17b2..ab4d390592 100644 --- a/daemon/images/image_push.go +++ b/daemon/images/image_push.go @@ -2,7 +2,6 @@ package images // import "github.com/docker/docker/daemon/images" import ( "context" - "errors" "io" "time" @@ -12,7 +11,6 @@ import ( "github.com/docker/docker/api/types/registry" "github.com/docker/docker/distribution" progressutils "github.com/docker/docker/distribution/utils" - "github.com/docker/docker/errdefs" "github.com/docker/docker/pkg/progress" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) @@ -23,7 +21,7 @@ func (i *ImageService) PushImage(ctx context.Context, ref reference.Named, platf // Check if the image is actually the platform we want to push. _, err := i.GetImage(ctx, ref.String(), backend.GetImageOpts{Platform: platform}) if err != nil { - return errdefs.InvalidParameter(errors.New("graphdriver backed image store doesn't support multiplatform images")) + return err } } start := time.Now()