Docker v2 separate build and push task issue
See original GitHub issueWe are using AZure DevOps Docker v2 tasks for building and pushing our docker images. We are pushing them to Azure Container registry.
First we used buildAndpush
command, but because we need some build arguments (not supported by buildAndpush
) we needed to split it.
Here is the excerpt from build yaml:
$(imageTag) is set above as example `2019-10_dev_63cf6d0`
....
- task: Docker@2
displayName: DockerBuild
inputs:
command: build
Dockerfile: src/WebApi/Dockerfile.prod
buildContext: src
tags: $(imageTag)
arguments: '--build-arg PAT=$(AzureDevOpsPAT)'
- task: Docker@2
displayName: DockerPush
inputs:
containerRegistry: AzureContainerRegistryDev
repository: eservice
command: push
tags: $(imageTag)
The build
task completes successfully. The problem is when push command is running.
We get:
Starting: DockerPush
==============================================================================
Task : Docker
Description : Build or push Docker images, login or logout, or run a Docker command
Version : 2.157.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/docker
==============================================================================
/usr/bin/docker push ***/***service:`2019-10_dev_63cf6d0`
The push refers to repository [***/***service]
An image does not exist locally with the tag: ***/***service
##[error]An image does not exist locally with the tag: ***/***service
##[error]The process '/usr/bin/docker' failed with exit code 1
Finishing: DockerPush
It looks like we are missing docker tag
command? I checked the log of the buildAndPush
task and indeed after it builds the image it tags it and then push it:
Successfully built 0b7e240d0373
Successfully tagged ***/***service:2019-10_dev_7e568d6
/usr/bin/docker push ***/***service:2019-10_dev_7e568d6
I’ve looked at the source code of the task and it’s strange, no evidence of docker tag
command. Any ideas?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Docker@2 - Docker v2 task - Microsoft Learn
A Docker task configured using the buildAndPush command ignores the arguments passed because they become ambiguous to the internal build and ...
Read more >Seperate build and push without defining containerRegistry in ...
My question is: How can I do this within azure devops without having to define the "containerRegistry" in the build task? The problem...
Read more >Multi-stage builds - Docker Documentation
With multi-stage builds, you use multiple FROM statements in your Dockerfile. Each FROM instruction can use a different base, and each of them...
Read more >Using –build-args with docker in Azure DevOps Pipelines
The background around this problem is that I want to add in some ... task: Docker@2 displayName: 'Build and Push Docker Image' inputs: ......
Read more >Pipeline Docker Task Build & Push fails to push image to ...
Pushing an image from command line on a remote machine after docker login works, so I think is not a credentials o registry...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, I’ve figure it out. The
buildAndPush
calls tag in build script, and mine didn’t so I changed the docker build task to:And now I am a happy camper 😄
What worked for me was to put the registry connection service in the Build task.