fabric8io / docker-maven-plugin

Maven plugin for running and creating Docker images
https://dmp.fabric8.io
Apache License 2.0
1.88k stars 642 forks source link

docker:push fails with Unable to add tag / no such id / Not found: 404 #602

Open johnplanow opened 7 years ago

johnplanow commented 7 years ago

Description

docker:push fails during tagging trying to get a tagged image that doesn't exist yet. See stack trace at the bottom.

At this point, aside from messing with different versions of docker, I'm somewhat at a loss. I would welcome any advice.

Suspecting configuration problems related to tagging, I've tried multiple approaches:

                              <image>
                                <registry>${docker.push.registry}</registry>
                                <name>${docker.image.name}:${docker.image.tag}</name>
                                <alias>source</alias>
                                <build>
                                    <dockerFileDir>${docker.build.directory}</dockerFileDir>
                                    <assembly>
                                        <basedir>/</basedir>
                                        <mode>dir</mode>
                                    </assembly>
                                </build>
                            </image>

As well as:

                              <image>
                                <registry>${docker.push.registry}</registry>
                                <name>${docker.image.name}</name>
                                <alias>source</alias>
                                <build>
                                    <dockerFileDir>${docker.build.directory}</dockerFileDir>
                                    <assembly>
                                        <basedir>/</basedir>
                                        <mode>dir</mode>
                                    </assembly>
                                    <tags>
                                        <tag>${docker.scmBranch}</tag>
                                        <tag>${docker.image.tag}</tag>
                                    </tags>
                                </build>
                            </image>

The exception is the same in either case.

I enabled maven's debug output (this was with the second configuration above) and saw the following HTTP requests during docker:push..

Executing request GET /version HTTP/1.1

Executing request GET /v1.18/images/repo.int.company.com%3A5002%2Fcom%2Fcompany%2Fservices%2Fmy-api%3Alatest/json HTTP/1.1

Executing request POST /v1.18/images/com%2Fcompany%2Fservices%2Fmy-api%3Alatest/tag?tag=latest&repo=repo.int.company.com%3A5002%2Fcom%2Fcompany%2Fservices%2Fmy-api&force=0 HTTP/1.1

Executing request POST /v1.18/images/repo.int.company.com%3A5002%2Fcom%2Fcompany%2Fservices%2Fmy-api/push?force=1 HTTP/1.1

Executing request DELETE /v1.18/images/repo.int.company.com%3A5002%2Fcom%2Fcompany%2Fservices%2Fmy-api%3Alatest?force=0 HTTP/1.1

Executing request GET /v1.18/images/repo.int.company.com%3A5002%2Fcom%2Fcompany%2Fservices%2Fmy-api%3Afeature-US12345/json HTTP/1.1 ^^^ Note that the response to this is: "No such image: repo.int.company.com:5002/com/company/services/my-api:feature-US12345[\n]" [DEBUG] http-outgoing-0 << HTTP/1.1 404 Not Found"

Executing request POST /v1.18/images/com%2Fcompany%2Fservices%2Fmy-api%3Afeature-US12345/tag?tag=feature-US12345&repo=repo.int.company.com%3A5002%2Fcom%2Fcompany%2Fservices%2Fmy-api&force=0 HTTP/1.1 ^^^ And the response to this is: ""HTTP/1.1 404 Not Found[\r][\n]"

Info

  • d-m-p version: 0.15.11 and 0.16.9
  • Maven version (mvn -v) : 3.2.5
  • What: Question

    Stack Trace:

[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.15.11:push (docker-push) on project my-api-docker: Unable to add tag [repo.int.company.com:5002/com/company/services/my-api:feature-US12345] to image [com/company/services/my-api:feature-US12345]: no such id: com/company/services/my-api:feature-US12345 (Not Found: 404) -> [Help 1] [DEBUG] Connection manager is shutting down org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.fabric8:docker-maven-plugin:0.15.11:push (docker-push) on project my-api-docker: Unable to add tag [repo.int.company.com:5002/com/company/services/my-api:feature-YS12345] to image [com/company/services/my-api:feature-US12345] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) at org.apache.maven.cli.MavenCli.main(MavenCli.java:199) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to add tag [repo.int.company.com:5002/com/company/services/my-api:feature-US12345] to image [com/company/services/my-api:feature-US12345] at io.fabric8.maven.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:199) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207) ... 20 more Caused by: io.fabric8.maven.docker.access.DockerAccessException: Unable to add tag [repo.int.company.com:5002/com/company/services/my-api:feature-US12345] to image [com/company/services/my-api:feature-US12345] at io.fabric8.maven.docker.access.hc.DockerAccessWithHcClient.tag(DockerAccessWithHcClient.java:362) at io.fabric8.maven.docker.access.hc.DockerAccessWithHcClient.tagTemporaryImage(DockerAccessWithHcClient.java:493) at io.fabric8.maven.docker.access.hc.DockerAccessWithHcClient.pushImage(DockerAccessWithHcClient.java:341) at io.fabric8.maven.docker.PushMojo.executeInternal(PushMojo.java:59) at io.fabric8.maven.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:196) ... 22 more Caused by: io.fabric8.maven.docker.access.hc.http.HttpRequestException: no such id: com/company/services/my-api:feature-US12345 (Not Found: 404) at io.fabric8.maven.docker.access.hc.ApacheHttpClientDelegate$StatusCodeCheckerResponseHandler.handleResponse(ApacheHttpClientDelegate.java:172) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:222) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:139) at io.fabric8.maven.docker.access.hc.ApacheHttpClientDelegate.post(ApacheHttpClientDelegate.java:93) at io.fabric8.maven.docker.access.hc.ApacheHttpClientDelegate.post(ApacheHttpClientDelegate.java:99) at io.fabric8.maven.docker.access.hc.DockerAccessWithHcClient.tag(DockerAccessWithHcClient.java:360) ... 27 more

johnplanow commented 7 years ago

Just noticed the first "inspect image" and "tag image" with tag latest...

Executing request GET /v1.18/images/repo.int.company.com%3A5002%2Fcom%2Fcompany%2Fservices%2Fmy-api%3Alatest/json HTTP/1.1

Executing request POST /v1.18/images/com%2Fcompany%2Fservices%2Fmy-api%3Alatest/tag?tag=latest&repo=repo.int.company.com%3A5002%2Fcom%2Fcompany%2Fservices%2Fmy-api&force=0 HTTP/1.1

.. get "404 Not found" and "201 Created" responses, respectively.

Unlike the second "inspect image" and "tag image" with tag feature-US12345...

Executing request GET /v1.18/images/repo.int.company.com%3A5002%2Fcom%2Fcompany%2Fservices%2Fmy-api%3Afeature-US12345/json HTTP/1.1

Executing request POST /v1.18/images/com%2Fcompany%2Fservices%2Fmy-api%3Afeature-US12345/tag?tag=feature-US12345&repo=repo.int.company.com%3A5002%2Fcom%2Fcompany%2Fservices%2Fmy-api&force=0 HTTP/1.1

As mentioned above, BOTH of these get "404 Not found" responses.

tapas4java commented 7 years ago

Any updated on this issue?? I also got same error on a fresh fabric8 setup instance.

johnplanow commented 7 years ago

Our case was perhaps a bit unique. We have a somewhat complicated Jenkins build using Maven, which is pushing docker images to a Nexus Repository that has a Docker registry plugin. I don't think the concerns raised in this issue were ultimately the source of our problems. We ultimately fixed it by cleaning up the workflow a little bit -- it seemed our issue was due to building and pushing the Docker image in separate Jenkins build phases.

However, I've left this issue open because the series of HTTP requests the plugin is making still seems potentially problematic.