docker / hub-feedback

Feedback and bug reports for the Docker Hub
https://hub.docker.com
232 stars 40 forks source link

OCI manifest found, but accept header does not support OCI manifests #2391

Closed z-hanzhe closed 3 months ago

z-hanzhe commented 3 months ago

Description

Content translated using ChatGPT, please forgive any errors.

I encountered an error while downloading Docker images. It says OCI manifest found, but accept header does not support OCI manifests, which is a strange problem. I tested with two images. The nginx:1.18.0-alpine image can be downloaded successfully, but the nginx:stable-alpine3.19-perl image fails to download. I'm not sure what the reason is behind this. Could you please help me figure it out?

Reproduce

I've outlined a process for downloading Docker images:

  1. Request the token for downloading from https://auth.docker.io/token?service=registry.docker.io&scope=repository:library/nginx:pull.
  2. Fetch the image manifest from https://registry-1.docker.io/v2/library/nginx/manifests/stable-alpine3.19-perl.
  3. Fetch the layer list from https://registry-1.docker.io/v2/library/nginx/manifests/sha256:xxx.

The issue arises in step 3. While nginx:1.18.0-alpine can be successfully fetched, nginx:stable-alpine3.19-perl returns an error message: OCI manifest found, but accept header does not support OCI manifests.

Expected behavior

I'm looking to resolve the issue where nginx:stable-alpine3.19-perl can successfully retrieve layer information.

z-hanzhe commented 3 months ago

image

jcarter3 commented 3 months ago

What client version are you using? (docker version, or whatever tool you are using) It sounds like what is happening is the images are stored in registry using the OCI manifest format, but the client you are using doesn't know what this is, and only accepts a media type of v2 docker manifest. If that's the case, updating the client should help.

z-hanzhe commented 3 months ago

What client version are you using? (docker version, or whatever tool you are using) It sounds like what is happening is the images are stored in registry using the OCI manifest format, but the client you are using doesn't know what this is, and only accepts a media type of v2 docker manifest. If that's the case, updating the client should help.

I'm not using the Docker client. I'm currently working on implementing a functionality to download images over HTTP without a Docker environment. I'm referring to the manifest-v2-2 specification document for this implementation. I've already mentioned the logic for API calls earlier.

z-hanzhe commented 3 months ago

The error message you're receiving after trying all the Media Types provided in the document is still persisting.

jcarter3 commented 3 months ago

This doesn't seem to be a problem with Docker (client, or registry), but rather a spec interpretation issue. I'm guessing you are missing setting application/vnd.oci.image.index.v1+json or application/vnd.oci.image.manifest.v1+json in your accept header, but maybe the CNCF slack is a better place for support.

z-hanzhe commented 3 months ago

This doesn't seem to be a problem with Docker (client, or registry), but rather a spec interpretation issue. I'm guessing you are missing setting application/vnd.oci.image.index.v1+json or application/vnd.oci.image.manifest.v1+json in your accept header, but maybe the CNCF slack is a better place for support.

nginx:stable-alpine3.19-perl:

{
    "manifests": [{
        "annotations": {
            "com.docker.official-images.bashbrew.arch": "amd64",
            "org.opencontainers.image.base.digest": "sha256:d1e71ea5319a3916725e44ba4aa230d24c17924389d44cbdab67b7abd41d3b78",
            "org.opencontainers.image.base.name": "nginx:1.26.1-alpine",
            "org.opencontainers.image.created": "2024-05-30T17:49:45Z",
            "org.opencontainers.image.revision": "3180cdbec313dc4a9f6dd1109ae66adaf98f11fb",
            "org.opencontainers.image.source": "https://github.com/nginxinc/docker-nginx.git#3180cdbec313dc4a9f6dd1109ae66adaf98f11fb:stable/alpine-perl",
            "org.opencontainers.image.url": "https://hub.docker.com/_/nginx",
            "org.opencontainers.image.version": "1.26.1-alpine-perl"
        },
        "digest": "sha256:2e3d8e3f04e9188e1738f3bf7e3d010d0bd3278734ed71f5c8e4a0dd33b6cdaf",
        "mediaType": "application/vnd.oci.image.manifest.v1+json",
        "platform": {
            "architecture": "amd64",
            "os": "linux"
        },
        "size": 2693
    }...],
    "mediaType": "application/vnd.oci.image.index.v1+json",
    "schemaVersion": 2
}

The error message persists even after attempting the digests sha256:2e3d8e3f04e9188e1738f3bf7e3d010d0bd3278734ed71f5c8e4a0dd33b6cdaf and sha256:d1e71ea5319a3916725e44ba4aa230d24c17924389d44cbdab67b7abd41d3b78, along with trying the accept headers application/vnd.oci.image.index.v1+json and application/vnd.oci.image.manifest.v1+json, as well as all other media types provided in the document.

image

jcarter3 commented 3 months ago

Also to clarify - the documentation you linked is not the documentation for Docker Hub - the official OCI specs are probably closer from a "what media types are allowed" perspective.

z-hanzhe commented 3 months ago

Also to clarify - the documentation you linked is not the documentation for Docker Hub - the official OCI specs are probably closer from a "what media types are allowed" perspective.

image

The effect I hope to achieve is to download Docker images via HTTP without the Docker client. However, after searching online for a long time, I couldn't find any related information. This document is the only one I found that might achieve this effect, but unfortunately, I encountered an unsolvable problem. Does Docker officially provide a method to download Docker images via HTTP?

jcarter3 commented 3 months ago

Yes, all of the calls are HTTP based. Perhaps a better piece of documentation to follow is this: https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pulling-manifests

z-hanzhe commented 3 months ago

Sorry, my issue is resolved. It was indeed the problem with the accept header that you mentioned at the beginning. The error was caused by a bug in my program, and I kept thinking it was an issue with DockerHub. Sorry about that.

jcarter3 commented 3 months ago

No problem, glad it's fixed!