MiguelSlv
MiguelSlv

Reputation: 15193

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://learn.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.

Upvotes: 2

Views: 1872

Answers (1)

Mengdi Liang
Mengdi Liang

Reputation: 19026

The push refers to repository [docker.io/library/azuretp]

According to this error message line, seems the task is pushing image to the root level of Docker hub, which is not allowed.


To solve it, please change the task from 0.* to 2.*

And then, input your docker repository name which listed in the Docker repository page by using the format: dockerhub_namespace/RepositoryName:

enter image description here

enter image description here

For YAML, please use below sample:

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

Upvotes: 4

Related Questions