通过REST在Azure容器注册表中处理图像

问题描述 投票:1回答:2

有没有办法使用REST API操作Azure容器注册表中的图像(删除,重新标记等)? an existing question的答案只提到了CLI。

rest azure docker azure-container-registry
2个回答
3
投票

答案是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

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);
});
© www.soinside.com 2019 - 2024. All rights reserved.