【问题标题】:Authentication Error when Building and Pushing docker image to ACR using Azure DevOps Pipelines and docker-compose使用 Azure DevOps Pipelines 和 docker-compose 构建和推送 docker 映像到 ACR 时的身份验证错误
【发布时间】:2021-06-22 12:00:50
【问题描述】:

我正在尝试使用 Azure DevOps 管道构建 docker 映像并将其推送到 ACR。我必须使用 docker-compose.yml 文件构建它才能在容器中使用 openvpn。

当我运行管道时,我收到以下错误。有没有人知道如何解决这个问题?

Starting: DockerCompose
==============================================================================
Task         : Docker Compose
Description  : Build, push or run multi-container Docker applications. Task can be used with Docker or Azure Container registry.
Version      : 0.183.0
Author       : Microsoft Corporation
Help         : https://aka.ms/azpipes-docker-compose-tsg
==============================================================================
/usr/local/bin/docker-compose -f /home/vsts/work/1/s/src/docker-compose.yml -f /home/vsts/agents/2.188.2/.docker-compose.1624362077551.yml -p Compose up -d
Creating network "composeproject_default" with the default driver
Pulling getstatus (***/getstatus:)...
Head https://***/v2/getstatus/manifests/latest: unauthorized: authentication required, visit https://aka.ms/acr/authorization for more information.
##[error]Creating network "composeproject_default" with the default driver
##[error]Pulling getstatus (***/getstatus:)...
##[error]Head https://***/v2/getstatus/manifests/latest: unauthorized: authentication required, visit https://aka.ms/acr/authorization for more information.
##[error]The process '/usr/local/bin/docker-compose' failed with exit code 1
Finishing: DockerCompose

我的 azure-pipelines.yml 看起来像这样:

# Docker
# Build and push an image to Azure Container Registry
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker

trigger:
- main

resources:
- repo: self

variables:
  # Container registry service connection established during pipeline creation
  dockerRegistryServiceConnection: '*****************************'
  imageRepository: 'getstatus'
  containerRegistry: 'composeproject.azurecr.io'
  dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile'
  tag: '$(Build.BuildId)'

  # Agent VM image name
  vmImageName: 'ubuntu-latest'


stages:
- stage: Build
  displayName: Build and push stage
  jobs:
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)
    steps:

    - task: Docker@2
      displayName: Build and push an image to container registry
      inputs:
        command: buildAndPush
        repository: $(imageRepository)
        dockerfile: $(dockerfilePath)
        containerRegistry: $(dockerRegistryServiceConnection)
        tags: |
          $(tag)

    - task: DockerCompose@0
      inputs:
        containerregistrytype: 'Azure Container Registry'
        dockerComposeFile: '**/docker-compose.yml'
        action: 'Run a Docker Compose command'
        dockerComposeCommand: 'up -d'

还有像这样的 docker-compose.yml:

version: "3.3"
services: 
  getstatus:
    image: composeproject.azurecr.io/getstatus
    restart: always
    sysctls:
      - net.ipv6.conf.all.disable_ipv6=0
    cap_add: 
      - NET_ADMIN
    devices:
      - /dev/net/tun
    volumes:
      - /etc/timezone:/etc/timezone:ro

【问题讨论】:

    标签: docker docker-compose azure-devops azure-container-registry azure-devops-pipelines


    【解决方案1】:

    我认为你的 docker compose 任务是missing a couple of parameters

    尝试添加azureContainerRegistry: composeproject.azurecr.ioazureSubscriptionEndpoint: $(dockerRegistryServiceConnection)

    不知道为什么 Docker@2 任务中提供的凭据由于它们处于同一阶段而不会持续存在,但是我可以用我不确定的关于 Azure 管道的内容填写百科全书

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-09-26
      • 2019-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多