【问题标题】:Getting a list of Containers from GCR从 GCR 获取容器列表
【发布时间】:2020-08-27 01:32:10
【问题描述】:

我目前可以使用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.set('Authorization', 'Basic ' + btoa(username + ":" + password));

【问题讨论】:

    标签: reactjs curl fetch google-container-registry


    【解决方案1】:

    所以我通过使用 ExpressJs 设置代理服务器来实现它,该代理服务器向 us.gcr.io 发出 HTTP 调用。然后,我从我的 react 应用程序调用 express 应用程序并能够获取数据:)

    【讨论】:

      【解决方案2】:

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

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

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

      根据描述:

      “gcloud 的 container images list 命令列出了指定仓库中现有容器镜像的元数据。仓库必须由 Google Container Registry 托管。”

      另一方面,我发现这个其他链接 [2] 可以为您服务。


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

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

      【讨论】:

      • 感谢您的回复。以编程方式,我的意思是通过网络应用程序。我已经编辑了我的问题。这些链接提供了 CLI 命令,正如我在问题中所写的那样。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-28
      • 1970-01-01
      相关资源
      最近更新 更多