Does Google container registry support docker remote API V2

血红的双手。 提交于 2019-12-11 14:08:12

问题


I'm storing my docker images in my private Google Container Registry and I want to interact with the images through registry V2 APIs, such as getting tags of an image (/v2/:imageName/tags/list). I believe that it is supported, according to this link But I cannot found related documentation. Can anyone help me?


回答1:


Indeed it is (including that endpoint). You should be able to interact with it after authenticating in the standard way outlined here.

Feel free to reach out on gcr-contact@google.com also if you have any troubles.




回答2:


Just got answer from google support, hope this helps others:

$ export NAME=project-id/image
$ export BEARER=$(curl -u _token:$(gcloud auth print-access-token) https://gcr.io/v2/token?scope=repository:$NAME:pull | cut -d'"' -f 10)
$ curl -H "Authorization: Bearer $BEARER" https://gcr.io/v2/$NAME/tags/list



回答3:


To add to Quyen Nguyen Tuan's answer, if you don't want to have to use gcloud at all, create a service account, pass the username _json_key and use the service account's json key as the password instead:

$ export NAME=project-id/image
$ export BEARER=$(curl -u "_json_key:$(cat path/to/json/key.json)" "https://gcr.io/v2/token?scope=repository:$NAME:pull" | cut -d'"' -f 10)
$ curl -H "Authorization: Bearer $BEARER" https://gcr.io/v2/$NAME/tags/list

and remember to prefix appropriately (e.g. eu.gcr.io) if that's where your repo is.



来源:https://stackoverflow.com/questions/34037256/does-google-container-registry-support-docker-remote-api-v2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!