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: how can I copy image between registries for multiple OS/arch ? #1557

Closed
developer-guy opened this issue Feb 7, 2023 · 2 comments · Fixed by #1561
Closed

question: how can I copy image between registries for multiple OS/arch ? #1557

developer-guy opened this issue Feb 7, 2023 · 2 comments · Fixed by #1561
Labels
question Further information is requested

Comments

@developer-guy
Copy link
Contributor

developer-guy commented Feb 7, 2023

I noticed that the platform flag in copy command only accepts a single value, and if you specify multiple platform flags, the last one will win. So, it'd be good to support taking multiple values for the platform flag to be able to specify the exact platforms that people care about.

# will copy an image built for linux/amd64
$ crane copy --platform linux/amd64

# will copy an image built for linux/arm64
$ crane copy --platform linux/arm64

# will copy an image built for linux/amd64, it ignores linux/arm64, but it'd be copy this image for each platform.
$ crane copy --platform linux/arm64 --platform linux/amd64
@developer-guy developer-guy added the question Further information is requested label Feb 7, 2023
@jonjohnsonjr
Copy link
Collaborator

jonjohnsonjr commented Feb 7, 2023

If you copy the whole multi-arch image, you get everything, but I assume you only want to copy things you care about?

I can interpret this three ways:

  1. Copy linux/arm64 and linux/amd64 images separately, do not push a multi-platform image.
  2. Synthesize a new multi-platform image that only contains linux/arm64 and linux/amd64.
  3. Copy only the linux/arm64 and linux/amd64 child images, then attempt to push the multi-platform image as-is, hoping that the registry supports sparse indexes.

The first one would be straightforward to implement, but I'm guessing it's not what you want.

The second one I would hesitate to add to copy but maybe we can have a flag for the behavior. This was requested in #1143 already.

The third one would make sense, but probably wouldn't work with almost all existing registries.

Any of those seem like what you want?

@jonjohnsonjr
Copy link
Collaborator

jonjohnsonjr commented Feb 7, 2023

FWIW you could hack around this a bit with crane edit manifest, but it's certainly not elegant.

$ crane manifest ubuntu | jq '.manifests |= map(select(.platform | .os == "linux" and (.architecture == "amd64" or .architecture == "arm64")))'
{
  "manifests": [
    {
      "digest": "sha256:c985bc3f77946b8e92c9a3648c6f31751a7dd972e06604785e47303f4ad47c4c",
      "mediaType": "application/vnd.oci.image.manifest.v1+json",
      "platform": {
        "architecture": "amd64",
        "os": "linux"
      },
      "size": 424
    },
    {
      "digest": "sha256:61bd0b97000996232eb07b8d0e9375d14197f78aa850c2506417ef995a7199a7",
      "mediaType": "application/vnd.oci.image.manifest.v1+json",
      "platform": {
        "architecture": "arm64",
        "os": "linux",
        "variant": "v8"
      },
      "size": 424
    }
  ],
  "mediaType": "application/vnd.oci.image.index.v1+json",
  "schemaVersion": 2
}

Piping that into crane edit manifest <your destination image> would attempt to write the filtered index, but it would fail unless you copied each sub-image first, which would be easy if we implemented option 1, but is possible with a little shell scripting.

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

Successfully merging a pull request may close this issue.

2 participants