且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何以编程方式从GCP注册表中获取已发布的Docker映像列表

更新时间:2023-02-12 19:37:26

当前没有针对Google Container Registry产品的REST API,但是您可以 HTTP请求:

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 

您可以使用命令 gcloud auth print-access-token 获得 accessToken .推荐的方法是它属于serviceAccount.

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

尽管我不确定 Docker Registry HTTP API V2 是否完整与Google Container Registry兼容,此特定方法对我有效.

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.