I’m building a java spring boot app docker container on Azure DevOps using the spring boot maven plugin. After that I want to push it to an azure container registry. But it fails with
An image does not exist locally with the tag: ***/my/container
Unfortunately the start of the container uri is masked with ***
. But as you can see in the output of /usr/bin/docker images
below, the container is registered. I tried to follow this example: https://medium.com/@TimvanBaarsen/build-your-spring-boot-project-using-azure-pipelines-in-azure-devops-3305977991d
Pipeline steps
steps:
- task: Maven@3
displayName: "Build Docker image"
inputs:
mavenPomFile: 'pom.xml'
goals: 'spring-boot:build-image'
publishJUnitResults: false
jdkVersionOption: '1.11'
mavenOptions: '-Xmx3072m -Dspring-boot.build-image.imageName=acr-foobar.azurecr.io/my/container'
- task: Docker@2
displayName: Push Docker image
inputs:
containerRegistry: 'acr-foobar.azurecr.io'
repository: 'my/container'
command: 'push'
tags: 'latest'
Output Maven Task
[INFO] Successfully built image 'acr-***/my/container:latest'
Output Docker Task
Starting: Push Docker image
==============================================================================
Task : Docker
Description : Build or push Docker images, login or logout, start or stop containers, or run a Docker command
Version : 2.176.0
Author : Microsoft Corporation
Help : https://aka.ms/azpipes-docker-tsg
==============================================================================
/usr/bin/docker images
/usr/bin/docker push ***/my/container:latest
REPOSITORY TAG IMAGE ID CREATED SIZE
paketobuildpacks/run base-cnb 523e5e0ad089 6 days ago 87.2MB
node 10 2457d5f85d32 13 days ago 911MB
node 10-alpine b328632eb00c 13 days ago 83.6MB
node 12 1f560ce4ce7e 4 weeks ago 918MB
buildpack-deps stretch b39de549c36a 4 weeks ago 835MB
buildpack-deps buster f3f98451c17d 4 weeks ago 804MB
debian 9 c4ccba324c9c 4 weeks ago 101MB
debian 8 091099bf65ad 4 weeks ago 129MB
node 12-alpine d8b74300d554 4 weeks ago 89.6MB
ubuntu 14.04 df043b4f0cf1 7 weeks ago 197MB
jekyll/builder latest a8007cad4069 2 months ago 677MB
alpine 3.9 78a2ce922f86 6 months ago 5.55MB
alpine 3.10 be4e4bea2c2e 6 months ago 5.58MB
alpine 3.8 c8bccc0af957 9 months ago 4.41MB
alpine 3.7 6d1ef012b567 20 months ago 4.21MB
mcr.microsoft.com/azure-pipelines/node8-typescript latest 9a948d360778 2 years ago 595MB
gcr.io/paketo-buildpacks/builder base-platform-api-0.3 6248029341bb 40 years ago 568MB
acr-***/my/container latest 61477479d5e0 40 years ago 283MB
The push refers to repository [***/my/container]
An image does not exist locally with the tag: ***/my/container
##[error]An image does not exist locally with the tag: ***/my/container
##[error]The process '/usr/bin/docker' failed with exit code 1
Finishing: Push Docker image
What’s wrong here?
2
Answers
In my case
I noticed that in the build and publish tasks specify a registry name if the
containerRegistry
value is set or the service connection exists. My publish step was specifying this attribute, but my build step was not.I changed the build step to also pass in this parameter, and the correct tags were created across both steps to resolve the issue.
Can try this hope it may help you.
It looks like the container built container image tag is
acr-***/my/container
and the image tag you are trying to push is***/my/container
So for some reason, it is cutting off theacr-
from the tag name.This is probably because there is an issue with the name of your Azure Container Registry. It should not allow a hyphen in its name.
Are you sure, that your container registry is called
acr-foobar.azurecr.io
?