buildx: build cache format in registry is incorrect
Following is an example of cache pushed to hub registry using --cache-to=type=registry flag:
{
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"manifests": [
{
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
"digest": "sha256:0057xxx",
"size": 24532,
"annotations": {
"buildkit/createdat": "2019-10-21T12:27:45.739079211Z",
"containerd.io/uncompressed": "sha256:b23fxxx"
}
},
...
}
The media type inside the manifests array should be either application/vnd.docker.distribution.manifest.v2+json or application/vnd.docker.distribution.manifest.v1+json according to the docker manifest list spec. Moreover while it is ok to use annotations with docker images since it is backward compatible the right place to use them should be OCI index/images. cc @dmcgowan
This is reported in https://github.com/docker/hub-feedback/issues/1906.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 22 (9 by maintainers)
I understand that nowadays we have different needs, but the Docker spec is very clear and precise about this IMO, and registries have been following that:
Fully agree. I guess the point is, while we don’t have an ultimate solution (which will take a long time to be adopted), what’s the easiest and smallest change that can:
I might be biased, but changing how several registries work to conform with something out of spec (IMO) seems to be the hardest way.
Just chiming in here: a manifest can be any typed content. The spec does not restrict it to just “manifests”.
@tonistiigi, thanks for providing some historical context. From what I see, it was due to Quay. However, today, it’s still not possible to push/pull cache images to/from Quay, just like for the majority of the SaaS registries (including ECR, GCR, Artifactory).
The underlying reason seems to be the same as the one we’re concerned about here. So I don’t think it’s fair to say this is “because someone wrote a new doc or didn’t understand the implications of code that they copy-pasted”.
The spec says: “An encountered mediaType that is unknown to the implementation MUST be ignored.” The problem is that the media type being used (
application/vnd.oci.image.layer.v1.tar+gzip) is not unknown to OCI registries. It’s well known, and it’s the media type of an OCI layer, not a manifest.Still, even with a fake media type, this would fail against most registries because these are not uploaded through the manifest API but rather the blob API (because they are not manifests), so they are not linked in the right places then found when the index arrives. So this ties back to the manifest vs. layer conversation, but we don’t seem to agree on that.
Please note that the only reason this currently works against the Distribution registry (maintainer here) is because of an old workaround (which converged blobs and manifests links), for which there is a PR to revert it (https://github.com/distribution/distribution/pull/3365). So the existing compatibility with this specific registry is due to a side effect, not by design (IMO).
That’s correct, and this seems to be a great fit for artifacts. However, even for those, the manifest vs. layer is respected whenever applicable. Otherwise, it’s not compatible with most registries, like cache images. For Helm charts (layer order doesn’t matter as well), for example (source):
Index:
Manifest:
This does not go against any of the relationship/reference rules, so it should work with most registries if they follow the spec and “ignore an unknown media type”, which applies perfectly to this case.
Yeah, the order is important, but I’d argue that that only matters if we’re concerned about creating containers based on these images, which is not the case for cache images, as you mention.
Based on all of this, if a manifest was used instead of an index/list, the result would be:
In regards to backward compatibility, maybe we could:
Does this seem technically feasible?
I don’t believe that this is true reading the spec: https://github.com/opencontainers/image-spec/blob/master/image-index.md
A layer is not a manifest, so having a layer within the manifests array here violates the spec from my understanding.