本文介绍了如何以编程方式从GCP注册表中获取已发布的Docker映像列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到一些API(例如Java,但也可以是其他一些API)如何从Google Cloud Platform注册中心获取已发布的Docker映像名称/标签.我发现了如何使用gcloud控制台命令执行此操作:

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.

推荐答案

当前没有针对Google Container Registry产品的REST API,但是您可以使用注册表名称作为URL 并运行 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.

这篇关于如何以编程方式从GCP注册表中获取已发布的Docker映像列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 18:55