cue-labs / oci

Go modules related to OCI (Open Container Initiative) registries
Apache License 2.0
24 stars 4 forks source link

`Accept:` header is missing `application/vnd.docker.distribution.manifest.v2+json` #22

Closed tianon closed 10 months ago

tianon commented 10 months ago

https://github.com/cue-labs/oci/blob/14751940d5b22f24e01c024cc61a3138565f8c7e/ociregistry/ociclient/client.go#L216-L227

This is missing application/vnd.docker.distribution.manifest.v2+json, which means doing lookups on a registry which has funky Accept: behavior (like, say, Docker Hub) doesn't correctly fetch images built with docker build (classic, not buildkit/buildx) / pushed with docker push (without the new containerd integration enabled).

I'm sure there are better examples, but the image I was testing and have handy is winamd64/hello-world:nanoserver-ltsc2022 -- see https://explore.ggcr.dev/?image=winamd64/hello-world:nanoserver-ltsc2022

Without adding application/vnd.docker.distribution.manifest.v2+json in that block of code I've linked above, I get Hub's automatically downgraded application/vnd.docker.distribution.manifest.v1+prettyjws manifest instead, but it works fine when I add it (at first I thought it was the order of that list, but have confirmed it's just the entries missing the Docker v2 type).

tianon commented 10 months ago

(I also have no idea what application/vnd.docker.container.image.v1+json is, but it's not hurting anything being there :smile:)

tianon commented 10 months ago

Ah that's the image config for the example I linked -- probably doesn't need to be in the Accept list, especially since it's only used for fetching manifests:

https://github.com/cue-labs/oci/blob/14751940d5b22f24e01c024cc61a3138565f8c7e/ociregistry/ociclient/client.go#L235-L240

mvdan commented 10 months ago

cc @rogpeppe

rogpeppe commented 10 months ago

@tianon Thanks very much for the report! Should be fixed by https://review.gerrithub.io/c/cue-labs/oci/+/1176474.