diff --git a/daemon/containerd/image_pull.go b/daemon/containerd/image_pull.go index 3e556ef068..7cd15a013a 100644 --- a/daemon/containerd/image_pull.go +++ b/daemon/containerd/image_pull.go @@ -13,6 +13,7 @@ import ( "github.com/distribution/reference" "github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/registry" + "github.com/docker/docker/distribution" "github.com/docker/docker/errdefs" "github.com/docker/docker/pkg/progress" "github.com/docker/docker/pkg/streamformatter" @@ -73,8 +74,12 @@ func (i *ImageService) PullImage(ctx context.Context, image, tagOrDigest string, finishProgress := jobs.showProgress(ctx, out, pp) defer finishProgress() - var sentPullingFrom bool + var sentPullingFrom, sentSchema1Deprecation bool ah := images.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) { + if desc.MediaType == images.MediaTypeDockerSchema1Manifest && !sentSchema1Deprecation { + progress.Message(out, "", distribution.DeprecatedSchema1ImageMessage(ref)) + sentSchema1Deprecation = true + } if images.IsManifestType(desc.MediaType) { if !sentPullingFrom { progress.Message(out, tagOrDigest, "Pulling from "+reference.Path(ref)) @@ -104,6 +109,10 @@ func (i *ImageService) PullImage(ctx context.Context, image, tagOrDigest string, infoHandler := snapshotters.AppendInfoHandlerWrapper(ref.String()) opts = append(opts, containerd.WithImageHandlerWrapper(infoHandler)) + // Allow pulling application/vnd.docker.distribution.manifest.v1+prettyjws images + // by converting them to OCI manifests. + opts = append(opts, containerd.WithSchema1Conversion) + img, err := i.client.Pull(ctx, ref.String(), opts...) if err != nil { return err diff --git a/distribution/errors.go b/distribution/errors.go index da0c841e07..366a1956db 100644 --- a/distribution/errors.go +++ b/distribution/errors.go @@ -212,3 +212,7 @@ func (e reservedNameError) Error() string { } func (e reservedNameError) Forbidden() {} + +func DeprecatedSchema1ImageMessage(ref reference.Named) string { + return fmt.Sprintf("[DEPRECATION NOTICE] Docker Image Format v1, and Docker Image manifest version 2, schema 1 support will be removed in an upcoming release. Suggest the author of %s to upgrade the image to the OCI Format, or Docker Image manifest v2, schema 2. More information at https://docs.docker.com/go/deprecated-image-specs/", ref) +} diff --git a/distribution/pull_v2.go b/distribution/pull_v2.go index 47b3fe9133..e8a17fc2bb 100644 --- a/distribution/pull_v2.go +++ b/distribution/pull_v2.go @@ -435,7 +435,7 @@ func (p *puller) pullTag(ctx context.Context, ref reference.Named, platform *oci switch v := manifest.(type) { case *schema1.SignedManifest: - msg := fmt.Sprintf("[DEPRECATION NOTICE] Docker Image Format v1, and Docker Image manifest version 2, schema 1 support will be removed in an upcoming release. Suggest the author of %s to upgrade the image to the OCI Format, or Docker Image manifest v2, schema 2. More information at https://docs.docker.com/go/deprecated-image-specs/", ref) + msg := DeprecatedSchema1ImageMessage(ref) log.G(ctx).Warn(msg) progress.Message(p.config.ProgressOutput, "", msg) @@ -868,7 +868,7 @@ func (p *puller) pullManifestList(ctx context.Context, ref reference.Named, mfst switch v := manifest.(type) { case *schema1.SignedManifest: - msg := fmt.Sprintf("[DEPRECATION NOTICE] Docker Image Format v1, and Docker Image manifest version 2, schema 1 support will be removed in an upcoming release. Suggest the author of %s to upgrade the image to the OCI Format, or Docker Image manifest v2, schema 2. More information at https://docs.docker.com/go/deprecated-image-specs/", ref) + msg := DeprecatedSchema1ImageMessage(ref) log.G(ctx).Warn(msg) progress.Message(p.config.ProgressOutput, "", msg)