gpt4 book ai didi

docker - 将容器推送到 Azure 容器注册表时拒绝资源访问

转载 作者:行者123 更新时间:2023-12-02 19:27:01 25 4
gpt4 key购买 nike

使用 Docker Compose 将容器推送到私有(private) Azure 容器注册表时,Azure DevOps 管道返回以下错误:

Pushing [container] ([registry]/[app]:latest)...

The push refers to repository [docker.io/[registry]/[container]]

denied: requested access to the resource is denied

azure-pipeline.yml 文件取自 Microsoft 微服务 eShopOnContainer 示例中显示的 Docker Compose 示例,here :

variables:
azureContainerRegistry: myregistry
azureSubscriptionEndpoint: My Service Principle
...
task: DockerCompose@0
displayName: Compose push customer API
inputs:
containerregistrytype: Azure Container Registry
azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
azureContainerRegistry: $(azureContainerRegistry)
dockerComposeCommand: 'push [container]'
dockerComposeFile: docker-compose.yml
qualifyImageNames: true
projectName: ""
dockerComposeFileArgs: |
TAG=$(Build.SourceBranchName)

服务原则在AcrPush role .

最佳答案

解决方案是明确容器名称。 documentation具有误导性,因为它首先声明:containerregistrytype 默认为 Azure Container Registry。该示例继续将 Contoso 作为 azureContainerRegistry 的值。

这是错误的。您需要将其显式设置为 Azure 中的“登录服务器”值。因此注册表应该是“contoso.azurecr.io”。所以完整的例子应该是:

variables:
azureContainerRegistry: contoso.azurecr.io
azureSubscriptionEndpoint: Contoso
steps:
- task: DockerCompose@0
displayName: Container registry login
inputs:
containerregistrytype: Azure Container Registry
azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
azureContainerRegistry: $(azureContainerRegistry)

这就是为什么它所指的推送 repo 实际上是:docker.io(公共(public) docker hub),因为它实际上必须是默认的,它解释了访问被拒绝的错误。

关于docker - 将容器推送到 Azure 容器注册表时拒绝资源访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55421635/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com