Azure Devops Docker Push: An image does not exist locally with the tag
Asked Answered
G

2

7

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?

Getupandgo answered 10/11, 2020 at 17:46 Comment(2)
have you tried Tagging the image using the "docker tag" command.Holds
@Robin-ManuelThiel hmm yeah exactly what I noticed, too. But I don't know how to further investigate it, because it's some masking logic from azure devops :(Timothea
A
5

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 the acr- 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.

enter image description here

Are you sure, that your container registry is called acr-foobar.azurecr.io?

Aborn answered 10/11, 2020 at 19:0 Comment(2)
interesting. I need to check this with the guy who manages the registry, tomorrow. Thanks. acr-*** is the name of the service connection. I need to find out the registry url.Timothea
Dear all, am facing the same issue " Successfully built c703c5e5bddd Successfully tagged myapp:70 az cli task :...Login Succeeded Error response from daemon: No such image: myapp:latest The push refers to repository [xxx.azurecr.io/myapp] An image does not exist locally with the tag: xxx.azurecr.io/myapp".Acupuncture
H
15

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.

Holds answered 10/11, 2020 at 18:0 Comment(3)
but as you can see: I have no docker build tasks. I'm using the spring boot plugin to do the build of the container.Timothea
It's the same issue as in https://mcmap.net/q/795383/-build-and-push-a-docker-image-with-build-arguments-from-devops-to-acr/2952093 (and the same solution)Vasos
Although it doesn't seem to be the answer for original poster, this sorted it for me, thanks AshokDent
A
5

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 the acr- 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.

enter image description here

Are you sure, that your container registry is called acr-foobar.azurecr.io?

Aborn answered 10/11, 2020 at 19:0 Comment(2)
interesting. I need to check this with the guy who manages the registry, tomorrow. Thanks. acr-*** is the name of the service connection. I need to find out the registry url.Timothea
Dear all, am facing the same issue " Successfully built c703c5e5bddd Successfully tagged myapp:70 az cli task :...Login Succeeded Error response from daemon: No such image: myapp:latest The push refers to repository [xxx.azurecr.io/myapp] An image does not exist locally with the tag: xxx.azurecr.io/myapp".Acupuncture

© 2022 - 2024 — McMap. All rights reserved.