簡體   English   中英

通過REST使用Azure Container Registry中的圖像

[英]Working with images in Azure Container Registry via REST

有沒有一種方法可以使用REST API在Azure容器注冊表中操作圖像(刪除,重新標記等)? 現有問題的答案僅提及CLI。

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

這是一些有關如何使用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);
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM