Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot temporarily tag because target image already exists #838

Closed
NancyChunlan opened this issue Aug 14, 2017 · 20 comments · Fixed by #1300
Closed

Cannot temporarily tag because target image already exists #838

NancyChunlan opened this issue Aug 14, 2017 · 20 comments · Fixed by #1300

Comments

@NancyChunlan
Copy link

NancyChunlan commented Aug 14, 2017

Sometimes when we have target image already existing in system, and so caused the docker-maven-plugin failed to temporarily tag. After checked, found following code.

 if (!name.hasRegistry() && registry != null) {
            if (hasImage(targetImage)) {
                throw new DockerAccessException(
                    String.format("Cannot temporarily tag %s with %s because target image already exists. " +
                                  "Please remove this and retry.",
                                  name.getFullName(), targetImage));
            }

I guess it's abnormal to interrupt the docker push with such errors, is it possible to remove the exception or add a parameter to toggle on/off the exception?

@ayen-tibco
Copy link

Please remove this codeline as the user's docker version tag will take care of replacing it OR failing to let the user know of an existing tag image.

https://stackoverflow.com/questions/31605661/how-to-prevent-docker-images-on-docker-hub-from-being-overwritten

@adam42a
Copy link

adam42a commented Dec 6, 2017

Just hit this problem after changing my config from

            <configuration>
                <images>
                    <image>
                        <name>my-registry:12345/my-app</name>
                        <build>
                            <tags>
                                <tag>latest</tag>

to

            <configuration>
                <pushRegistry>my-registry:12345</pushRegistry>
                <images>
                    <image>
                        <name>my-app</name>
                        <build>
                            <tags>
                                <tag>latest</tag>

Is one way correct and one way wrong?

@gnboorse
Copy link

I am having this issue as well on several projects, but not on others.

Is there any update to the status of the code that @NancyChunlan pasted above?

@NancyChunlan
Copy link
Author

@gnboorse I didn't get any update yet, as workaround, we use script to remove target images before the plugin.

@gnboorse
Copy link

gnboorse commented Jun 7, 2018

@NancyChunlan we ended up moving away from this plugin actually. We are now doing the docker and java builds separately.

@rhuss
Copy link
Collaborator

rhuss commented Jun 13, 2018

Sorry for the super late response, not sure why this issue was below my radar.

I agree that we should be more conservative here and I'm going to tackle this for the next release.

blaxx pushed a commit to blaxx/docker-maven-plugin that referenced this issue Nov 28, 2018
rohanKanojia pushed a commit to rohanKanojia/docker-maven-plugin that referenced this issue Nov 28, 2018
@michaelze
Copy link

@rhuss
Any update on this? I'm running into the same issue and there have been two releases since your last post as far as I can tell.

jroper added a commit to jroper/docker-maven-plugin that referenced this issue Mar 5, 2019
Fixes fabric8io#838

There are a few reasons why such a tag might exist:

* Previous run was killed part way through push tag, resulting in the
finally block not running
* In my case, was previously manually tagging and pushing, but I didn't
clean up old tags, then I switched to using Fabric8

At any rate, I see no harm in overwriting the tag, since if doing it
manually, that's what you'd do anyway.
jroper added a commit to jroper/docker-maven-plugin that referenced this issue Mar 5, 2019
Fixes fabric8io#838

There are a few reasons why such a tag might exist:

* Previous run was killed part way through push tag, resulting in the
finally block not running
* In my case, was previously manually tagging and pushing, but I didn't
clean up old tags, then I switched to using Fabric8

At any rate, I see no harm in overwriting the tag, since if doing it
manually, that's what you'd do anyway.

Signed-off-by: James Roper <[email protected]>
@jroper
Copy link

jroper commented Mar 5, 2019

Fixed in #1170.

onap-github pushed a commit to onap/ci-management that referenced this issue Sep 6, 2019
Add three global templates needed to build multiarch images:
   - {project-name}-docker-manifest-{stream}: creates a docker
     manifest list with images for multiple architectures by calling
     docker_push_manifest.sh

   - {project-name}-multiarch-docker-stage-{stream}: multijob that
     uses the global-jjb template
     {project-name}-maven-docker-stage-{stream} to produce staging
     images for each supported arch and a manifest list for them

   - {project-name}-multiarch-{stream}-merge-java: multijob that uses
     the existing {project-name}-{stream}-merge-java template to
     produce snapshot images for each suppported arch and a manifest
     list for them

The policy/docker project jobs are modified to use the new multiarch
templates.
All images are now pushed to DockerHub instead of Nexus (as Nexus lacks
support for docker manifest list).

Cancel the triggers for child jobs, as they will be triggered by the
parent multiarch job.

For the jobs that build images, use registry registry-1.docker.io
as a workaround for [1].

Enable the multiarch jobs only for the master branch for now.

[1] fabric8io/docker-maven-plugin#838

Issue-ID: CIMAN-217
Change-Id: Ibd00d24bb70ef51f761005016b7baea4ef66a0a5
Signed-off-by: Paul Vaduva <[email protected]>
Signed-off-by: Cristina Pauna <[email protected]>
Signed-off-by: Alexandru Avadanii <[email protected]>
@yoursmanish
Copy link

when can we expect this to available in https://mvnrepository.com/artifact/io.fabric8/docker-maven-plugin
i am facing same issue with

<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.31.0</version>

@rohanKanojia
Copy link
Member

Hmm, I think most probably around Christmas. But Roland can answer it more precisely since he maintains it

@rhuss
Copy link
Collaborator

rhuss commented Dec 17, 2019

I will try to make a release before the end of the week, or early next week.

Sorry for the delay, year end stress here :)

@yoursmanish
Copy link

Hi @rhuss when do you think it can be released and will available in https://mvnrepository.com/?

@rhuss
Copy link
Collaborator

rhuss commented Jan 8, 2020

Sorry, PTO was more vacation than expected ;-) But now that I'm back on track, I'm already preparing the release so should be out at latest at the end of this week.

@ziqianggeoffreychen
Copy link

This issue is still observed occasionally in latest release v0.33.0
[INFO] --- docker-maven-plugin:0.33.0:push (push-when-install) @ my-project
[INFO] DOCKER> The push refers to repository [my repo]
[INFO] DOCKER> latest: digest: sha256:
[ERROR] DOCKER> Image <my_image>:latest could be pushed, but the temporary tag could not be removed

@nholtwerth
Copy link

nholtwerth commented Aug 10, 2020

Hi, I am also facing this error in v0.33.0.

@rhuss
Copy link
Collaborator

rhuss commented Aug 30, 2020

Could you please post a sample project so that could be reproduced ?

@ziqianggeoffreychen
Copy link

This issue is observed occasionally, or I can even say "rarely". The related projects are very common, nothing special.

@NancyChunlan
Copy link
Author

As checked, 0.32.0 has fixed this issue.
Logs as below:

05:18:39,969 [WARNING] DOCKER> Target image 'docker.registry/image' already exists. Tagging of 'image' will replace existing image

@NancyChunlan
Copy link
Author

Could you please post a sample project so that could be reproduced ?

This issue happened when we have the image tagged with docker registry, and if we tried to tag a new image with the same tag (with docker registry) for docker:push, it will be failed.

@jntigura
Copy link

jntigura commented Nov 3, 2021

Hi,
We're using docker-maven-plugin:0.37.0 and have intermittent occurrences of this bug with messages similar to this:
[INFO] --- docker-maven-plugin:0.37.0:push (push-docker-image) @ *** ---
...
[ERROR] DOCKER> Unable to push '***' to registry '***' : tag does not exist: *** [tag does not exist: *** ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet