gpt4 book ai didi

azure-devops - 将 Docker 镜像任务推送到 ACR 在 Azure DevOps Pipeline 中失败,错误为 "unauthorized: authentication required"

转载 作者:行者123 更新时间:2023-12-03 23:36:16 24 4
gpt4 key购买 nike

在 Azure DevOps 管道中推送和镜像到 Azure 容器注册表任务失败。以前的任务执行得很好,即。 docker 镜像创建成功,登录 ACR 成功。但是推送任务失败,结果如下:

unauthorized: authentication required
[error]unauthorized: authentication required
[error]/usr/bin/docker failed with return code: 1
[section]Finishing: Push Docker image

docker push 到给定的 acr 可以从本地命令行正常工作。
# Docker image
# Build a Docker image to deploy, run, or push to a container registry.
# Add steps that use Docker Compose, tag images, push to a registry, run an image, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker

trigger:
- master

pool:
vmImage: 'Ubuntu-16.04'

variables:
imageName: 'renamed:$(build.buildId)'
azureSubscriptionEndpoint: Renamed
azureContainerRegistry: renamed.azurecr.io
steps:
- task: Docker@1
displayName: Build docker image
inputs:
command: Build an image
dockerFile: Dockerfile
imageName: $(imageName)
containerregistrytype: Azure Container Registry
azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
azureContainerRegistry: $(azureContainerRegistry)
- task: Docker@1
displayName: Login to container registry
inputs:
command: login
containerregistrytype: Azure Container Registry
azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
azureContainerRegistry: $(azureContainerRegistry)
dockerFile: Dockerfile
imageName: $(imageName)
- task: Docker@1
displayName: Push Docker image
inputs:
command: Push an image
containerregistrytype: Azure Container Registry
azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
azureContainerRegistry: $(azureContainerRegistry)
imageName: $(imageName)

最佳答案

我在 Azure DevOps 中使用 Azure 容器注册表服务连接时遇到了同样的问题。

解决方法是在创建 Docker Registry 服务连接时不选择“Azure Container Registry”,而是选择“其他”。然后在 Azure 门户中启用容器注册表上的管理员用户并使用该凭据创建服务连接。

关于azure-devops - 将 Docker 镜像任务推送到 ACR 在 Azure DevOps Pipeline 中失败,错误为 "unauthorized: authentication required",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55495223/

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