Azure DevOps パイプラインの Azure Container Registry タスクへのプッシュとイメージが失敗します。前のタスクは正常に実行され、つまり、docker イメージが作成され、ACR へのログインが成功します。ただし、プッシュ タスクは次の結果で失敗します。
unauthorized: authentication required
[error]unauthorized: authentication required
[error]/usr/bin/docker failed with return code: 1
[section]Finishing: Push Docker image
指定された acr への docker push は、ローカル コマンド ラインから正常に機能します。
# 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://learn.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)
ベストアンサー1
Azure DevOps で Azure Container Registry サービス接続を使用したときにも同じ問題が発生しました。
回避策としては、Docker レジストリ サービス接続を作成するときに「Azure コンテナー レジストリ」を選択せず、代わりに「その他」を選択します。次に、Azure ポータルでコンテナー レジストリの管理者ユーザーを有効にし、その資格情報を使用してサービス接続を作成します。