Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Image indexes with multiple matching platforms #862

Closed
imjasonh opened this issue Jul 9, 2021 · 1 comment · Fixed by #880
Closed

Question: Image indexes with multiple matching platforms #862

imjasonh opened this issue Jul 9, 2021 · 1 comment · Fixed by #880

Comments

@imjasonh
Copy link
Member

imjasonh commented Jul 9, 2021

This image index is nominally compliant with image-spec, as I understand it:

{
 "schemaVersion": 2,
 "mediaType": "application/vnd.oci.image.index.v1+json",
 "manifests": [
  {
   "mediaType": "application/vnd.oci.image.manifest.v1+json",
   "size": 426,
   "digest": "sha256:8f3b47c7984464f417f9d5f5e232ac3fae6453e84f053724fef457c4ba67ceaf",
   "platform": {
    "architecture": "amd64",
    "os": "linux"
   }
  },
  {
   "mediaType": "application/vnd.oci.image.manifest.v1+json",
   "size": 426,
   "digest": "sha256:186b7bca3cb745dfc4bd6f2ec1cdf310f30e70ad795cd17bbee6698cc9f3aacc",
   "platform": {
    "architecture": "amd64",
    "os": "linux"
   }
  }
}

Note that it has two manifests, each with an identical platform (linux+amd64), but each pointing to a different image manifest digest.

The question is: what should a client do when asked to pull and run a platform-dependent image in this index?

Based on local experimentation, docker pull (v20.10.6) pulls the first item it finds in the list, and logs a debug message if it saw 2+ that matched the target platform (1, 2). Incidentally, a brief code search doesn't find any unit tests covering this behavior in the docker CLI codebase. 😬

I don't know how other clients would handle this case, and AFAIK this platform matching behavior isn't governed by any OCI spec. It would be easy to imagine a client changing their behavior either accidentally or on purpose and surprising users. A malicious image could be pulled and executed innocuously on certain runtimes and maliciously on others.

What guidance should OCI give for clients attempting to match a platform in an index, when they encounter multiple matching platforms? Should distribution-spec recommend rejecting pushes for such an index?

Other considerations:

  • the two matching manifests might point to identical digests, in which case the difference is moot 🤷‍♂️
  • the two matching manifests might point to identical digests, but with different sizes, only one of which might be valid, but there's no way to know without pulling the manifest by digest -- should it just fail?
  • the two matching manifests might have different mediaTypes, of which multiple might be valid and others not -- should it just fail?
  • there might be N matching manifests, with any combination of the above issues

What OCI spec(s), if any, should govern this behavior?

Is an index containing multiple images with the same platform considered valid on purpose?

@jonjohnsonjr
Copy link
Contributor

X-ref: #776

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants