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:
I have verified Dockerregistry service connection and it is connected with dockerhub credential.
From the Configure tab, select the Docker - Build and push an image to Azure Container Registry task. Select your Azure Subscription, and then select Continue. Select your Container registry from the dropdown menu, and then provide an Image Name to your container image. Select Validate and configure when you are done.
Sign in to your Azure DevOps organization and navigate to your project. Select Pipelines, and then New Pipeline. Select GitHub when prompted for the location of your source code, and then select your repository. Select the Docker: build and push an image to Azure Container Registry pipeline template.
Steps: Add task docker->switch the task version to 0->select the option Run a Docker command , then we could run the docker save command, check the pic below. Is there any better way of doing this apart from saving an image. We recommend that you use this to upload the docker image as an artifact. Save this answer.
You need to switch the Docker task version from 0.*
to 2.*
.
Then you need to define also your Docker hub repository name:
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.
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 .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With