Azure 容器注册表权限

标签 azure docker

我正在尝试使用 Azure AD 设置对 Azure 容器注册表的简单只读访问。

我已成功设置具有只读访问权限的服务主体,没有问题,但是在创建 AD 帐户并在注册表上使用 IAM 时,我无法使用 az acr 登录。

我已在 Azure AD 中创建了一个帐户,将其添加到注册表 IAM,为其分配了读者角色(这与为服务主体指定的角色匹配),但使用 az acr 登录时收到以下错误

The client '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="473f3f3f3f073f3f3f3f3f3f69242869322c" rel="noreferrer noopener nofollow">[email protected]</a>' with object id 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' does not have authorization to perform action 'Microsoft.ContainerRegistry/registries/listCredentials/action' over scope '/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx/resourceGroups/xxxxxxxxxxxxx/providers/Microsoft.ContainerRegistry/registries/xxxxxxxxxxxx'.

使用 az acr 登录的唯一方法是分配对资源组的 IAM 贡献者权限。

我有什么遗漏吗?

蒂亚

最佳答案

这是一个 RBAC 问题。

您可以尝试使用此docker登录来登录ACR吗?

您还可以使用服务主体直接登录。向 docker 登录命令提供服务主体的应用 ID密码:

 docker login myregistry.azurecr.io -u xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -p myPassword

当您使用 az acr login 登录时,CLI 使用您执行 az login 时创建的 token 来无缝验证您的 session 您的注册表。

请检查您的服务主体权限,您也可以创建新的服务主体并分配给此

az ad sp create-for-rbac -n "http://my-app" --role reader --scopes /subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/mygroup

可用的角色有:

读者:拉
贡献者:拉和推
所有者:拉取、推送以及将角色分配给其他用户

注意:

当您使用az acr login登录acr时,此命令将使用您执行az acr login时创建的 token 来登录它。此 token 等于您的服务主体(读取器)。

关于Azure 容器注册表权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48754308/

相关文章:

python - Docker构建ubuntu :xenial issue

linux - 为什么 crond 无法在 alpine linux 上运行非根 crontab?

Angular Docker 热重载不适用于 Windows

docker - 在 GitLab CI/CD 作业中将环境变量传递给 docker run 返回无效的引用格式?

azure - 在运行时从 Azure Data Bricks Pipeline 传递 Databricks ClusterID

azure - 使用 Azure Devops Pipeline 的 Docker .NET(非核心)

c# - X509Store.Certificates.Find 将 validOnly 设置为 true 不会返回中间机构证书

php - 如何在 docker 容器中重新启动 php-fpm?

c# - 在 OnMessageOptions 中使用 ExceptionReceived

azure - 使用 VPN 连接到 Azure SQL 数据库(点到站点)