从 GCR 获取容器列表

Getting a list of Containers from GCR

我目前可以使用 curl -u "oauth2accesstoken:token-value" https://gcr.io/v2/_catalog 来获取我的注册表中的容器列表,有没有办法通过网络应用程序做到这一点?

我已尝试使用 fetch('https://us.gcr.io/v2/_catalog',{method:'GET', headers:header }).then(res=>console.log(res)).catch(err=>console.log(err));,但一直收到 405 CORS 错误。我做错了什么还是这根本不可能?

我的header是header.set('Authorization', 'Basic ' + btoa(username + ":" + password));

我了解到您想要从 GCR 获取容器列表。

为此,您可以使用 gcloud 命令“gcloud container images list”

您可以在其文档参考 [1] 中找到更多详细信息。

根据描述:

“gcloud 的容器镜像列表命令列出了指定存储库中现有容器镜像的元数据。存储库必须由 Google 容器注册表托管。”

另一方面,我发现另一个 link [2] 可能对您有用。


[1] https://cloud.google.com/sdk/gcloud/reference/container/images/list

[2]

所以我通过使用 ExpressJs 设置代理服务器来使它工作,该代理服务器对 us.gcr.io 进行了 HTTP 调用。然后,我从我的 React 应用程序调用了 Express 应用程序并能够获取数据:)