在 Azure Devops Pipeline 中将 Docker 映像拉取和推送到 ACR 任务失败“未经授权:无效的 clientid 或客户端密钥”。

Neo*_*ron 8 yaml azure docker azure-pipelines acr

在 Azure DevOps 管道中将映像推送和拉取到 Azure 容器注册表任务失败。当尝试从本地系统拉取或推送时,没有问题,但当尝试使用 Azure Devops 管道执行此操作时,则会失败。Docker 登录成功,但当我想从 ACR 中提取镜像时失败,结果如下:

**Error response from daemon: Head "***/a2/abcd/manifest/latest": unauthorized: Invalid clientid or client secret. 

##[error]Bash exited with code '1'.
##[debug]Processed: ##vso[task.issue type=error;]Bash exited with code '1'. 
Run Code Online (Sandbox Code Playgroud)

我检查了 Az Devops 中的所有服务连接,它们看起来都配置正确。还检查了关联的服务主体是否具有AcrPull权限AcrPush,所有这些都已到位。只是不明白出了什么问题。

我的 Yaml 看起来像这样:

trigger: none
schedules:
- cron: "0 0 0 * *"
  displayName: ****  *
  branches:
    include:
    - abcd
  always: true

pool:
  vmImage: 'ubuntu-latest'

variables:
- name: acrname
  value: *****.azurecr.io


stages:
- stage: abcd
  displayName: "pull images from acr"
  jobs:
  - job: abcdef
    displayName: "abcdef"
    pool:
      vmImage: ubuntu-latest
    steps:
      - task: Docker@2
        displayName: Login to ACR
        inputs:
          command: login
          containerRegistry: '*****.azurecr.io'
          

      - bash: |
            docker pull $(acrname)/abc-def:latest
            docker pull $(acrname)/igh-jkl:latest
        name: pull
        displayName: 'pull acr images'

Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?

iam*_*991 10

  1. 我遇到了同样的问题,ACR 服务连接已过期。因此,我必须使用这些步骤创建新的服务连接。

在此输入图像描述

  1. Docker ID 和 Docker 密码可以从 ACR --> 设置 --> 访问密钥获取

在此输入图像描述

  1. 使用这个新的服务连接更新您的管道,您就可以开始了。如果此解决方案对您有帮助,请评分。