有没有办法使用 REST API 来操作 Azure 容器注册表中的图像(删除、重新标记等)?现有问题的答案仅提及 CLI。
问问题
2202 次
2 回答
9
答案是 ACR 实现了Docker Registry API,所以那里列出的所有命令也适用于 Azure 注册表中的图像。这与Resource Manager REST 接口不同,后者用于注册表本身的操作。
要进行身份验证,ACR 文档中列出了各种选项,包括通过 AAD 或使用用户名/密码:https ://github.com/Azure/acr/blob/master/docs/AAD-OAuth.md
例如,这是AAD-OAuth.md
列出注册表中所有图像/存储库的脚本:
#!/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
于 2018-08-20T07:21:38.560 回答
0
这是一些关于如何使用 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);
});
于 2019-03-05T10:03:25.533 回答