4
votes

I have a .Net core web application with a Dockerfile.

I am using Azure DevOps pipeline to build the docker image, and want to push that image on Docker Hub.

But when I run the pipeline, it fails while pushing image with below error:

2019-07-25T07:40:39.2332684Z ##[section]Starting: Push an image
2019-07-25T07:40:39.2340807Z ==============================================================================
2019-07-25T07:40:39.2340932Z Task         : Docker
2019-07-25T07:40:39.2341017Z Description  : Build, tag, push, or run Docker images, or run a Docker command
2019-07-25T07:40:39.2341132Z Version      : 0.154.1
2019-07-25T07:40:39.2341206Z Author       : Microsoft Corporation
2019-07-25T07:40:39.2341308Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/docker
2019-07-25T07:40:39.2341405Z ==============================================================================
2019-07-25T07:40:39.4058071Z e6868ba4-0951-4724-b13b-58e178dacb79 exists true
2019-07-25T07:40:39.5494209Z [command]/usr/bin/docker push dockerDemo2019:19
2019-07-25T07:40:39.5780069Z The push refers to repository [docker.io/library/dockerDemo2019]
2019-07-25T07:40:40.5429692Z b0f339cf7b16: Preparing
2019-07-25T07:40:40.5430778Z a385a9a129e2: Preparing
2019-07-25T07:40:40.5431098Z 6339615de93e: Preparing
2019-07-25T07:40:40.5431279Z c6c9de941dfa: Preparing
2019-07-25T07:40:40.5431433Z 9c894eb0930b: Preparing
2019-07-25T07:40:40.5431696Z d56055da3352: Preparing
2019-07-25T07:40:40.5431855Z d56055da3352: Waiting
2019-07-25T07:40:42.4737943Z denied: requested access to the resource is denied
2019-07-25T07:40:42.4880225Z ##[error]denied: requested access to the resource is denied
2019-07-25T07:40:42.4932585Z ##[error]/usr/bin/docker failed with return code: 1
2019-07-25T07:40:42.4960825Z ##[section]Finishing: Push an image

My pipeline setup:

enter image description here

I have verified Dockerregistry service connection and it is connected with dockerhub credential.

2
In the Docker task version switch it to version 2.* (I think you are in 0.*)Shayki Abramczyk
@ShaykiAbramczyk: you were correct, After changing it to 2.0*, build was successfull, but with warning No repository is specified. Nothing will be pushed.Amit Kumar
Check my answer :)Shayki Abramczyk

2 Answers

7
votes

You need to switch the Docker task version from 0.* to 2.*.

Then you need to define also your Docker hub repository name:

enter image description here

enter image description here

The same thing you need to do also in the build step - switch to 2.* and define the repository name.

By the way - in the 2.* version, the action name is buildAndPush, which combines both the build and push tasks.

0
votes

My Service Connection was the issue in my case . I messed it up as the default was "Others" .

After setting the Registry Type to DockerHub and subsequently setting up credentials , it worked fine .

Ofcourse the steps suggested by [![https://stackoverflow.com/users/7409220/shayki-abramczyk] were important too .

enter image description here