首页 > 解决方案 > Push to docker repository fail on AzurePipelines

问题描述

The task Docker push fail to push the image into docker hub.

The yml:

steps:
- task: Docker@0
  displayName: 'Push an image'
  inputs:
    containerregistrytype: 'Container Registry'
    dockerRegistryConnection: 'docker hub'
    action: 'Push an image'

The log:

Starting: Push an image
==============================================================================
Task         : Docker
Description  : Build, tag, push, or run Docker images, or run a Docker command
Version      : 0.157.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/docker
==============================================================================
dbef9fd1-06fb-47eb-af36-bf86b4d44152 exists true
"C:\Program Files\Docker\docker.exe" push azuretp:38
The push refers to repository [docker.io/library/azuretp]
f2369ebe2bed: Preparing
...
537ddf9b819a: Waiting
denied: requested access to the resource is denied
##[error]C:\Program Files\Docker\docker.exe failed with return code: 

The connection docker hub is correct. I just reenter the credentials and Azure pipeline validate it successfully.

The problem seams to be with the path, according to this post, but i can't find a way to specify my docker hub name within this task.

标签: azureazure-devopsazure-pipelinesazure-pipelines-tasks

解决方案


推送是指存储库 [docker.io/library/azuretp]

根据此错误消息行,似乎任务是将映像推送到 Docker 集线器的根级别,这是不允许的。


要解决它,请将任务从更改0.*2.*

然后,使用以下格式输入您在Docker 存储库页面中列出的 docker 存储库名称dockerhub_namespace/RepositoryName

在此处输入图像描述

在此处输入图像描述

对于 YAML,请使用以下示例:

steps:
- task: Docker@2
  displayName: push
  inputs:
    containerRegistry: {service connection name}
    repository: {dockerhub_namespace/RepositoryName}
    command: push

推荐阅读