How to get list of published docker images from GCP registry programmatically

与世无争的帅哥 提交于 2021-02-05 05:51:28

问题


I'm trying to find some API (for example java, but could be some other) how to get published docker image names / tags from google cloud platform registry. I found how to do this using gcloud console commands:

gcloud container images list-tags gcr.io/[GCP_REPOSITORY_NAME]

And it basically gave what I want, but it is console and I need this data get programmatically on back-end side. Any ideas guys? Thanks in advance.


回答1:


Currently there is no REST API for the Google Container Registry product but you can use the Registry name as an URL and run an HTTP request within your Java code against it:

curl -u "oauth2accesstoken:yourAccessToken" https://gcr.io/v2/yourProject/yourImage/tags/list 

You can get the accessToken with the command gcloud auth print-access-token. The recommend approach is that it belongs to a serviceAccount.

Although I am not sure if the Docker Registry HTTP API V2 is fully compatible with Google Container Registry, this specific method has worked for me.



来源:https://stackoverflow.com/questions/55059636/how-to-get-list-of-published-docker-images-from-gcp-registry-programmatically

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