Skip to content

Support multiple --platform where appropriate #1945

Closed

Description

@polarathene

What is the version of your ORAS CLI

1.3.0

What would you like to be added?

Since oras is already capable of handling multiple platforms where appropriate (such as oras cp), it would be ideal if --platform could support a list of preferred platforms.


Potentially support a wildcard syntax as a shorthand for filtering a group of platforms. For example when parsing an image index, filtering platforms returned by applying the wildcard pattern. For example:

  • All archs for a given OS.
  • All variants of an arch.
  • All OS with a specific arch.
# Single platform (already supported):
oras cp docker.io/library/caddy:latest --to-oci-layout oras-caddy --platform linux/arm64

# Multiple platforms (unsupported, requires repeating the command with a different `--platform`):
oras cp docker.io/library/caddy:latest --to-oci-layout oras-caddy --platform 'linux/amd64,linux/arm64'
oras cp docker.io/library/caddy:latest --to-oci-layout oras-caddy --platform linux/amd64 --platform linux/arm64

# Multiple platforms with wildcard (unsupported):
oras cp docker.io/library/caddy:latest --to-oci-layout oras-caddy --platform 'linux/*'
oras cp docker.io/library/caddy:latest --to-oci-layout oras-caddy --platform 'linux/arm*'
oras cp docker.io/library/caddy:latest --to-oci-layout oras-caddy --platform '*/arm64'

I don't have a specific requirement for the related wildcard filtering, it is just something familiar with Docker Bake --set and HCL "splat", along with other tools that support a similar filter/selection pattern.

Why is this needed for ORAS?

When using oras cp the default behaviour for an image index is to pull all platforms.

When using --platform explicitly, whichever the last specified option was is the platform that will be stored. The command must be invoked multiple times with a different platform each time.

For an image index like docker.io/library/caddy:latest this is not only multi-arch but multi-platform, with the windows images variants using several GB while the Alpine linux images are considerably smaller (approx 20MB each). I was interested in using oras cp with only the linux platform as I had no need for the windows platform to be copied (nor the spare disk space in this case).


With a single --platform, the oras cp results in making a copy of just the image manifest (eg: with an OCI layout index.json) rather than an implicitly creating an image index (thus would need to be manually constructed afterwards to support tags referring to both archs).

Likewise for images built via Docker, their docker build attestation feature attaches unknown platforms to the image index which would also be lost:

Example for AMD64 platform with associated attestation manifest
{
  "manifests": [
    {
      "annotations": {
        "com.docker.official-images.bashbrew.arch": "amd64",
        "org.opencontainers.image.base.digest": "sha256:85f2b723e106c34644cd5851d7e81ee87da98ac54672b29947c052a45d31dc2f",
        "org.opencontainers.image.base.name": "alpine:3.22",
        "org.opencontainers.image.created": "2025-10-08T23:21:09Z",
        "org.opencontainers.image.revision": "5572371a83e48fd0368a4917d0fc48e44ef30582",
        "org.opencontainers.image.source": "https://github.com/caddyserver/caddy-docker.git#5572371a83e48fd0368a4917d0fc48e44ef30582:2.10/alpine",
        "org.opencontainers.image.url": "https://hub.docker.com/_/caddy",
        "org.opencontainers.image.version": "2.10.2-alpine"
      },
      "digest": "sha256:5c18f4b845cd8f2cbb344ffa6fe0391d8c975ed921848c9968298f1eb8940a97",
      "mediaType": "application/vnd.oci.image.manifest.v1+json",
      "platform": {
        "architecture": "amd64",
        "os": "linux"
      },
      "size": 1916
    },
    {
      "annotations": {
        "com.docker.official-images.bashbrew.arch": "amd64",
        "vnd.docker.reference.digest": "sha256:5c18f4b845cd8f2cbb344ffa6fe0391d8c975ed921848c9968298f1eb8940a97",
        "vnd.docker.reference.type": "attestation-manifest"
      },
      "digest": "sha256:c49b5bb9fafca5664bab24f64ba8ed9dbf93ef119619a617a6452dbf94aaec01",
      "mediaType": "application/vnd.oci.image.manifest.v1+json",
      "platform": {
        "architecture": "unknown",
        "os": "unknown"
      },
      "size": 840
    },

I wouldn't expect that to be supported by this feature request, since filtering by platform would lack context (technically the image manifest is referenced via vnd.docker.reference.digest) and either result in none or all (IIRC the Docker maintainers were opposed to supporting the OCI tag fallback for when the Referrer API was unavailable, which is the case with GHCR last I checked).

Are you willing to submit PRs to contribute to this feature?

  • Yes, I am willing to implement it.

Activity

  1. added
    enhancement
    triage
    on Dec 15, 2025
  2. TerryHowe commented on Dec 15, 2025

    @TerryHowe
    Member

    Sounds like a cool idea although might not be so simple to actually implement because I doubt the spec would support a wildcard, so we'd have to iterate over the list of supported platforms.

  3. wangxiaoxuan273 commented on Dec 16, 2025

    @wangxiaoxuan273
    Contributor

    @FeynmanZhou Maybe we should consider this. Related discussion in #1531

  4. polarathene commented on Dec 16, 2025

    @polarathene
    Author

    might not be so simple to actually implement because I doubt the spec would support a wildcard

    Yeah I understand that. I was just throwing the wildcard matching as a complimentary DX improvement. Realistically I'm not likely to being using such in a manual manner much, and I have no concern with verbosity when automating.

    Being able to filter to a subset with a delimited list would be more useful for adhoc testing, like I described with image manifest vs image index from the copy.

    docker imagetools create has a --prefer-index option as an alternative, although that's for creating an image index even with a single image.

  5. FeynmanZhou commented on Jan 6, 2026

    @FeynmanZhou
    Member

    Thanks @polarathene for the proposal. Sounds like a valid scenario to me as well. Are you interested in contributing to this feature?

  6. added
    help wanted
    and removed
    triage
    on Jan 6, 2026
  7. polarathene commented on Jan 7, 2026

    @polarathene
    Author

    I am not a Go dev, nor do I have the time atm to spare 😓 I may attempt to contribute at a later date but welcome anyone else to tackle it in the meantime.

  8. bimakw commented on Jan 10, 2026

    @bimakw
    Contributor

    Hey, I'll take this.

    Looked at the code - platform flag is in cmd/oras/internal/option/platform.go, just need to switch StringVarP to StringSliceVarP.

    Checked oras-go too, WithTargetPlatform still only takes single platform, so I'll loop at CLI level for now. Will send a PR soon.

  9. polarathene commented on Jan 11, 2026

    @polarathene
    Author

    @bimakw you should look at the PR referencing this issue just before your comment, it seems someone has already tackled this: #1954 (comment)

  10. bimakw commented on Jan 11, 2026

    @bimakw
    Contributor

    Ah my bad, didn't notice @hellocn9 already put up #1954. Looks solid, I'll leave this one to them.

  11. github-actions commented on Mar 13, 2026

    @github-actions

    This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

  12. added
    stale
    on Mar 13, 2026
  13. added and removed
    stale
    on Mar 23, 2026
  14. added this to the v2.0.0 milestone on Mar 23, 2026
  15. TerryHowe commented on Sep 11, 2026

    @TerryHowe
    Member

    Can someone else pick. this up, #1954 was very close

  16. rune-gh commented on Oct 13, 2026

    @rune-gh

    I want to work on this. I'll pick up from where #1954 left off with a fresh implementation (multi-value --platform flag + CLI-level copy loop), keeping the scope to the delimited list per the discussion. Will open a PR once it's ready.

  17. rune-gh commented on Oct 13, 2026

    @rune-gh

    Update: checking current main, this is already implemented by #2191 (merged Sept 30, "feat(cp): support multiple platforms") — it covers comma-delimited + repeatable --platform, filtered-index subset copies, and attestation handling. #1945 appears to remain open only because #2191's Fixes line referenced #2163 instead. Withdrawing my claim above; #1945 can be closed as completed by #2191 via #2163.

  18. TerryHowe commented on Oct 22, 2026

    @TerryHowe
    Member

    Implemented by #2191 (merged 2026-09-30): oras cp now accepts comma-delimited and repeatable --platform. That PR referenced #2163, so this issue didn't auto-close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issuehelp wantedkeep open

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions