如何使用HTTP API从gcr.io Docker注册表中列出图像和标签?

如何使用HTTP API从gcr.io Docker注册表中列出图像和标签?,第1张

如何使用HTTP API从gcr.io Docker注册表中列出图像和标签?

在与GCR的乔恩·约翰逊(Jon
Johnson)进行广泛交流之后,我们终于弄清楚了哪里出了问题。如果您赞成这个答案,请也赞成乔恩(Jon’s),他超越了这一点,以解决此问题。

截止本文撰写之时,其中大部分内容尚未记录在案。

  • 需要使用
    registry:catalog:*
    范围。
  • 我的图像被推送到
    us.gcr.io
    ,并将它们视为单独的注册表-我认为它们是镜子。
  • 服务帐户必须
    Project Viewer
    在Google Cloud IAM中具有角色。
  • 您可以使用GCR令牌以及Google Cloud令牌。但是,尽管GCR令牌不能与一起使用
    Basic base64(_token:<token>)
    ,但Google Cloud令牌可以使用。

获取GCR令牌

// Updated hostaxios.get('https://us.gcr.io/v2/token?service=gcr.io', {  params: {    service: 'us.gcr.io',    scope: `registry:catalog:*`  },  auth: {    username: '_token',    password: token // token I got from `google-auto-auth`  },  })

使用令牌列出存储库

const client = axios.create({  baseURL: `https://us.gcr.io/v2`,  headers: {    Authorization: `Bearer ${token}`  }})client.get('/_catalog').then((response) => {  console.log(response.data.repositories)})


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5012570.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-14
下一篇 2022-11-14

发表评论

登录后才能评论

评论列表(0条)

保存