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

crane copy v1 image to registry which only supports v2 fails #732

Open
dvob opened this issue Jun 18, 2020 · 7 comments
Open

crane copy v1 image to registry which only supports v2 fails #732

dvob opened this issue Jun 18, 2020 · 7 comments

Comments

@dvob
Copy link
Contributor

dvob commented Jun 18, 2020

When I try to copy an image with a v1 schema to a registry which only supports v2 (docker registry dropped the support for v1 images by default in 2.7.0) I get the following error:

$ crane copy quay.io/k8scsi/livenessprobe:v2.0.0 localhost:5000/k8scsi/livenessprobe:v2.0.0
...
failed to copy schema 1 image: PUT http://localhost:5000/v2/k8scsi/livenessprobe/manifests/v2.0.0: UNKNOWN: unknown error; map[]

Is it possible to convert the image to a v2 schema? It seems that this got already discussed in #377 (comment) but i could not find the appropriate code.

Steps to reproduce:

docker run -it --rm -p 5000:5000 --name registry registry:2.7.1
crane copy quay.io/k8scsi/livenessprobe:v2.0.0 localhost:5000/k8scsi/livenessprobe:v2.0.0
@jonjohnsonjr
Copy link
Collaborator

Yeah... we decided to abandon support for schema 1 images because doing so violates a lot of nice properties; e.g. normally you can verify a copy by checking image digests, but if we transparently upgraded schema 1 images, we obviously can't preserve the digest since we're changing the artifact.

I wouldn't be opposed to adding something that explicitly does this up-conversion, but I don't want that to happen automatically (it's very slow). Do you know if any tools exist to do this already? I know docker used to do this whenever you pushed an image that was pulled as schema 1, but installing docker can be a pain.

It seems that this got already discussed in #377 (comment) but i could not find the appropriate code.

This branch would be really useful to have -- I'm not sure what happened to it 🤦‍♂️

@dvob
Copy link
Contributor Author

dvob commented Jun 19, 2020

Do you know if any tools exist to do this already?

I tried the same with skopeo and first I thought it does not work with it either. But I missed the --format option. So yes, skopeo does support converting the format like this:

skopeo copy --insecure-policy --format v2s2 docker://quay.io/k8scsi/livenessprobe:v2.0.0 docker://localhost/k8scsi/livenessprobe:v2.0.0

For this skopeo uses the function https://godoc.org/github.com/containers/image/copy#Image with the ForceManifestMIMEType set in the Options struct.

It would be nice if the conversion would be supported in go-containerregistry library but I think it is not super urgent to us. We still would have the other problem you mentioned that we no longer can compare the digest to see if an image is up to date. So if we had the conversion feature we would have to change things there as well.

For us we currently see the following options (no particular order):

  • not support that case since v1 images are quite rare
  • migrate to the library used by skopeo since we have to change a couple of things either way
  • wait for conversion support in go-containerregistry

@github-actions
Copy link

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.

@dvob
Copy link
Contributor Author

dvob commented Oct 31, 2020

/remove-lifecycle stale

@jonjohnsonjr
Copy link
Collaborator

I'm considering revisiting the whole schema 1 up-conversion thing. Would that still be useful to you?

@dvob
Copy link
Contributor Author

dvob commented Dec 17, 2020

Yes, that would still be useful. We use go-containerregistry to sync images from various locations to a local registry and for that it is practical if crane copy works for all/most image formats.

@github-actions
Copy link

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.

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

No branches or pull requests

2 participants