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

Pushing an image with existing tag #1191

Closed
ueoeae opened this issue Nov 22, 2021 · 4 comments
Closed

Pushing an image with existing tag #1191

ueoeae opened this issue Nov 22, 2021 · 4 comments

Comments

@ueoeae
Copy link

ueoeae commented Nov 22, 2021

How do you handle a crane push of an image if the tag already exists in the registry? The push still happens if the tag exists, and overwrites previous push/tag.

@imjasonh
Copy link
Collaborator

In this case the push should still succeed and the tag should point to the newly pushed image.

This matches the behavior of docker push, etc.

Depending on the registry, the previous image may still be available by digest, or by any other tags it still has pointing to it.

@ueoeae
Copy link
Author

ueoeae commented Nov 22, 2021

In this case the push should still succeed and the tag should point to the newly pushed image.

This matches the behavior of docker push, etc.

Depending on the registry, the previous image may still be available by digest, or by any other tags it still has pointing to it.

Would you know of a possibility to check if the used tag already exists so that a push does not take place unless the tag is unique?

@imjasonh
Copy link
Collaborator

You can check for the existence of an image at a tag with crane digest, which will fail if the tag doesn't exist. Something like:

crane digest registry.com/my/image:tag && echo "tag exists" && exit 1
crane push image.tar registry.com/my/image:tag

If registry.com/my/image:tag exists then it won't be pushed to.

Beware there's a possible race condition, if you check for the existence of a tag then push to it; another process can push to that tag in the meantime. At this time there isn't a "push to this tag only if it doesn't exist yet" option, though enabling this across registries is being discussed in OCI: opencontainers/distribution-spec#250

@imjasonh
Copy link
Collaborator

Closing this, please reply if this didn't answer your question.

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

No branches or pull requests

2 participants