Closed ernestm closed 8 years ago
We have the same issue here. It looks like when trying to generate the same tag as before, the plugin fails with a 409.
Maybe it would be appropriate the plugin to remove the tagged image if exists and generate it again. Just like an overwrite.
This other plugin does exactly that: https://github.com/rhuss/docker-maven-plugin So you can build your image with the same tag multiple times, and in your docker images there will be just the latest tag and one for the version tag.
It is not documented in the README.md, but if you use:
<forceTags>true</forceTags>
in the main configuration tag for the plugin it will overwrite the previous tag. I'm using version 0.4.0.
fixed by #191
I have a docker build with just one imageTag being applied to it:
The whole build runs and then at the very end there's an error with applying the tag (output from mvn -X clean package docker:build):
[INFO] Tagging alienvault/otx-portal with 1.0.25-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 05:29 min [INFO] Finished at: 2016-02-11T13:26:17-06:00 [INFO] Final Memory: 24M/197M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.0:build (default) on project otx-portal: Exception caught: Request error: POST https://192.168.99.100:2376/images/alienvault/otx-portal/tag?repo=alienvault/otx-portal&tag=1.0.25-SNAPSHOT: 409: HTTP 409 Conflict -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.spotify:docker-maven-plugin:0.4.0:build (default) on project otx-portal: Exception caught at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216) 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:862) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) at org.apache.maven.cli.MavenCli.main(MavenCli.java:197) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) 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: Exception caught at com.spotify.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:115) at com.spotify.docker.BuildMojo.execute(BuildMojo.java:82) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 20 more Caused by: com.spotify.docker.client.DockerRequestException: Request error: POST https://192.168.99.100:2376/images/alienvault/otx-portal/tag?repo=alienvault/otx-portal&tag=1.0.25-SNAPSHOT: 409 at com.spotify.docker.client.DefaultDockerClient.propagate(DefaultDockerClient.java:1306) at com.spotify.docker.client.DefaultDockerClient.request(DefaultDockerClient.java:1277) at com.spotify.docker.client.DefaultDockerClient.tag(DefaultDockerClient.java:850) at com.spotify.docker.BuildMojo.tagImage(BuildMojo.java:556) at com.spotify.docker.BuildMojo.execute(BuildMojo.java:332) at com.spotify.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:113) ... 23 more Caused by: com.spotify.docker.client.shaded.javax.ws.rs.ClientErrorException: HTTP 409 Conflict at org.glassfish.jersey.client.JerseyInvocation.createExceptionForFamily(JerseyInvocation.java:1026) at org.glassfish.jersey.client.JerseyInvocation.convertToException(JerseyInvocation.java:1009) at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:799) at org.glassfish.jersey.client.JerseyInvocation.access$500(JerseyInvocation.java:91) at org.glassfish.jersey.client.JerseyInvocation$5.completed(JerseyInvocation.java:760) at org.glassfish.jersey.client.ClientRuntime.processResponse(ClientRuntime.java:197) at org.glassfish.jersey.client.ClientRuntime.access$300(ClientRuntime.java:78) at org.glassfish.jersey.client.ClientRuntime$2.run(ClientRuntime.java:179) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.process(Errors.java:267) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:340) at org.glassfish.jersey.client.ClientRuntime$3.run(ClientRuntime.java:209) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) [ERROR] [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
However, it seems to work - I end up with the image tagged both with the version and latest,
$ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE alienvault/otx-portal 1.0.25-SNAPSHOT a01b437a2d8f 16 seconds ago 652.4 MB alienvault/otx-portal latest a01b437a2d8f 16 seconds ago 652.4 MB ubuntu 14.04 6cc0fc2a5ee3 3 weeks ago 187.9 MB hello-world latest 0a6ba66e537a 4 months ago 960 B
If I run it a second time, I get the same error but the 10.0.25-SNAPSHOT tag isn't updated, it's still on the previous image.
I have no existing images for this image (docker images shows ubuntu and hello-world stuff) and no containers (docker ps -a empty). I'm using a Ubuntu 14.04 virtualbox docker-machine on OSX.
That's a problem, because a) even though it seems to turn out OK the build fail makes our CI system sad, and b) I need to tag the image specifically to upload it to Artifactory, and it's inside maven that it knows about the current version...
Any help is welcome.