通过REST在Azure容器注册表中处理图像
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通过REST在Azure容器注册表中处理图像相关的知识,希望对你有一定的参考价值。
有没有办法使用REST API操作Azure容器注册表中的图像(删除,重新标记等)? an existing question的答案只提到了CLI。
答案
答案是ACR实现了Docker Registry API,因此其中列出的所有命令也适用于Azure注册表中的图像。这与资源管理器REST接口截然不同,后者用于注册表本身的操作。
要进行身份验证,ACR文档中列出了各种选项,包括通过AAD或用户名/密码:https://github.com/Azure/acr/blob/master/docs/AAD-OAuth.md
例如,以下是来自AAD-OAuth.md
的脚本,用于列出注册表中的所有images / repos:
#!/bin/bash
export registry=" --- you have to fill this out --- "
export user=" --- you have to fill this out --- "
export password=" --- you have to fill this out --- "
export operation="/v2/_catalog"
export credentials=$(echo -n "$user:$password" | base64 -w 0)
export catalog=$(curl -s -H "Authorization: Basic $credentials" https://$registry$operation)
echo "Catalog"
echo $catalog
另一答案
这是一些关于如何使用Node.js获取图像列表的示例代码:
const httpreq = require('httpreq');
const server = '<get it from the Azure portal>';
const username = '<get it from the Azure portal>';
const password = '<get it from the Azure portal>';
httpreq.get(`https://${server}/v2/_catalog`, {
auth: `${username}:${password}`
}, (err, res) => {
if(err) return console.log(err);
var data = JSON.parse(res.body);
console.log(data);
});
以上是关于通过REST在Azure容器注册表中处理图像的主要内容,如果未能解决你的问题,请参考以下文章
仅从 Azure 存储 [Azure-Blob][REST] 中的 Blob 列表获取特定元数据
如何使用REST API将文件存储卷安装到azure容器实例
使用 ACR(天蓝色容器注册表)作为 Azure Devops json 管道的输入