moby/distribution
Sebastiaan van Stijn 62b33a2604
disable pulling legacy image formats by default
This patch disables pulling legacy (schema1 and schema 2, version 1) images by
default.

A `DOCKER_ENABLE_DEPRECATED_PULL_SCHEMA_1_IMAGE` environment-variable is
introduced to allow re-enabling this feature, aligning with the environment
variable used in containerd 2.0 (`CONTAINERD_ENABLE_DEPRECATED_PULL_SCHEMA_1_IMAGE`).

With this patch, attempts to pull a legacy image produces an error:

With graphdrivers:

    docker pull docker:1.0
    1.0: Pulling from library/docker
    [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 docker.io/library/docker:1.0 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/

With the containerd image store enabled, output is slightly different
as it returns the error before printing the `1.0: pulling ...`:

    docker pull docker:1.0
    Error response from daemon: [DEPRECATION NOTICE] Docker Image Format v1 and Docker Image manifest version 2, schema 1 support is disabled by default and will be removed in an upcoming release. Suggest the author of docker.io/library/docker:1.0 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/

Using the "distribution" endpoint to resolve the digest for an image also
produces an error:

    curl -v --unix-socket /var/run/docker.sock http://foo/distribution/docker.io/library/docker:1.0/json
    *   Trying /var/run/docker.sock:0...
    * Connected to foo (/var/run/docker.sock) port 80 (#0)
    > GET /distribution/docker.io/library/docker:1.0/json HTTP/1.1
    > Host: foo
    > User-Agent: curl/7.88.1
    > Accept: */*
    >
    < HTTP/1.1 400 Bad Request
    < Api-Version: 1.45
    < Content-Type: application/json
    < Docker-Experimental: false
    < Ostype: linux
    < Server: Docker/dev (linux)
    < Date: Tue, 27 Feb 2024 16:09:42 GMT
    < Content-Length: 354
    <
    {"message":"[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 docker.io/library/docker:1.0 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/"}
    * Connection #0 to host foo left intact

Starting the daemon with the `DOCKER_ENABLE_DEPRECATED_PULL_SCHEMA_1_IMAGE`
env-var set to a non-empty value allows pulling the image;

    docker pull docker:1.0
    [DEPRECATION NOTICE] Docker Image Format v1 and Docker Image manifest version 2, schema 1 support is disabled by default and will be removed in an upcoming release. Suggest the author of docker.io/library/docker:1.0 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/
    b0a0e6710d13: Already exists
    d193ad713811: Already exists
    ba7268c3149b: Already exists
    c862d82a67a2: Already exists
    Digest: sha256:5e7081837926c7a40e58881bbebc52044a95a62a2ea52fb240db3fc539212fe5
    Status: Image is up to date for docker:1.0
    docker.io/library/docker:1.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-02-28 13:57:43 +01:00
..
fixtures/validate_manifest Add distribution package 2015-11-24 09:40:24 -08:00
metadata distribution: format code with gofumpt 2023-06-29 00:30:52 +02:00
utils migrate to github.com/containerd/log v0.1.0 2023-10-11 17:52:23 +02:00
xfer api/types: move image options to api/types/image 2024-01-24 00:10:33 +01:00
config.go image: implement CheckOS, deprecate pkg/system IsOSSupported 2023-09-07 22:14:44 +02:00
errors.go disable pulling legacy image formats by default 2024-02-28 13:57:43 +01:00
errors_test.go distribution: un-export internal errors and error-utilities 2022-04-21 22:53:02 +02:00
manifest.go disable pulling legacy image formats by default 2024-02-28 13:57:43 +01:00
manifest_test.go disable pulling legacy image formats by default 2024-02-28 13:57:43 +01:00
pull.go distribution: Add Tags 2023-10-16 14:19:27 +02:00
pull_v2.go disable pulling legacy image formats by default 2024-02-28 13:57:43 +01:00
pull_v2_test.go vendor: github.com/docker/distribution v2.8.3 2023-10-11 17:11:25 +02:00
pull_v2_unix.go migrate to github.com/containerd/log v0.1.0 2023-10-11 17:52:23 +02:00
pull_v2_windows.go migrate to github.com/containerd/log v0.1.0 2023-10-11 17:52:23 +02:00
push.go migrate to github.com/containerd/log v0.1.0 2023-10-11 17:52:23 +02:00
push_v2.go migrate to github.com/containerd/log v0.1.0 2023-10-11 17:52:23 +02:00
push_v2_test.go migrate to new github.com/distribution/reference module 2023-09-05 12:09:26 +02:00
registry.go distribution: newRepository: remove naked return and intermediate vars 2023-09-08 15:44:58 +02:00
registry_unit_test.go migrate to github.com/containerd/log v0.1.0 2023-10-11 17:52:23 +02:00
repository.go daemon/cluster: Cluster.imageWithDigestString: include mirrors to resolve digest 2024-01-04 16:53:45 +01:00