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 <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2024-10-11 14:47:13 +02:00
parent c09e5265db
commit d31c241ea5

View File

@@ -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()