docker-maven-plugin
docker-maven-plugin copied to clipboard
autoRemove - Unable to remove container / No such container
Description
I have a rather simple use of the docker-maven-plugin where I wish to start a container for dev purposes and then later stop it. Running mvn -Pdev docker:start works just fine. However, running mvn -Pdev docker:stop always raises an exception like the following:
[DEBUG] DOCKER> shutdown will wait max of 0 seconds before removing container
[INFO] DOCKER> [existdb/existdb:6.1.0-SNAPSHOT] "existdb-semver-xq": Stop and removed container bcfa30aafb14 after 0 ms
[ERROR] DOCKER> At least one exception thrown during container removal.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.717 s
[INFO] Finished at: 2022-12-29T12:06:32+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.40.3:stop (default-cli) on project semver-xq: At least one exception thrown during container removal. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.fabric8:docker-maven-plugin:0.40.3:stop (default-cli) on project semver-xq: At least one exception thrown during container removal.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
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:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: At least one exception thrown during container removal.
at io.fabric8.maven.docker.AbstractDockerMojo.execute (AbstractDockerMojo.java:280)
at io.fabric8.maven.docker.StopMojo.execute (StopMojo.java:113)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
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:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: io.fabric8.maven.docker.access.DockerAccessException: At least one exception thrown during container removal.
at io.fabric8.maven.docker.StopMojo.stopContainers (StopMojo.java:181)
at io.fabric8.maven.docker.StopMojo.executeInternal (StopMojo.java:132)
at io.fabric8.maven.docker.AbstractDockerMojo.execute (AbstractDockerMojo.java:277)
at io.fabric8.maven.docker.StopMojo.execute (StopMojo.java:113)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
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:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Using the JDWP and placing a break point on line 181 of StopMojo.java, I can see that the supressed exception looks like this:
io.fabric8.maven.docker.access.DockerAccessException: Unable to remove container [6984e5833b5b] : {"message":"No such container: 6984e5833b5b"} (Not Found: 404)
The relevant stack trace for dae looks like:
io.fabric8.maven.docker.access.DockerAccessException: Unable to remove container [6984e5833b5b] : {"message":"No such container: 6984e5833b5b"} (Not Found: 404)
at io.fabric8.maven.docker.access.hc.DockerAccessWithHcClient.removeContainer(DockerAccessWithHcClient.java:507)
at io.fabric8.maven.docker.service.RunService.removeContainer(RunService.java:167)
at io.fabric8.maven.docker.service.RunService.removeContainer(RunService.java:633)
at io.fabric8.maven.docker.service.RunService.shutdown(RunService.java:584)
at io.fabric8.maven.docker.service.RunService.stopContainer(RunService.java:215)
at io.fabric8.maven.docker.StopMojo.stopContainers(StopMojo.java:154)
at io.fabric8.maven.docker.StopMojo.executeInternal(StopMojo.java:132)
at io.fabric8.maven.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:277)
at io.fabric8.maven.docker.StopMojo.execute(StopMojo.java:113)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)
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:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
Caused by: io.fabric8.maven.docker.access.hc.http.HttpRequestException: {"message":"No such container: 6984e5833b5b"} (Not Found: 404)
at io.fabric8.maven.docker.access.hc.ApacheHttpClientDelegate$StatusCodeCheckerResponseHandler.handleResponse(ApacheHttpClientDelegate.java:189)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:223)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:140)
at io.fabric8.maven.docker.access.hc.ApacheHttpClientDelegate.delete(ApacheHttpClientDelegate.java:68)
at io.fabric8.maven.docker.access.hc.ApacheHttpClientDelegate.delete(ApacheHttpClientDelegate.java:55)
at io.fabric8.maven.docker.access.hc.DockerAccessWithHcClient.removeContainer(DockerAccessWithHcClient.java:505)
... 30 more
The relevant section of my pom.xml looks like:
<profile>
<!--
Profile for rapid development and/or manual testing.
Simply run: `mvn -Pdev docker:start` to start a Docker environment of eXist-db on port 9090
with the semver.xq package already deployed.
As the Docker environment binds the files from the host filesystem, changes to the source code
are reflected immediately in the running eXist-db environment.
You can override the Docker host port for eXist-db from port 9090 to a port of your choosing by
specifying `-Ddev.port=9191`, e.g.: `mvn -Pdev -Ddev.port=9191 docker:start`.
If you also want the Dashboard and eXide to be available from the Docker environment of eXist-db
you can invoke the target `public-xar-repo:resolve` before you call `docker:start`,
e.g. `mvn -Pdev public-xar-repo:resolve docker:start`.
To stop the Docker environment run: `mvn -Pdev docker:stop`.
-->
<id>dev</id>
<properties>
<exist.version>6.1.0-SNAPSHOT</exist.version>
<dev.port>9090</dev.port>
</properties>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.40.3</version>
<configuration>
<skip>${skipTests}</skip>
<verbose>true</verbose>
<images>
<image>
<alias>existdb-semver-xq</alias>
<name>existdb/existdb:${exist.version}</name>
<run>
<ports>
<port>${dev.port}:8080</port>
</ports>
<volumes>
<bind>
<volume>${project.build.testOutputDirectory}/.expath-pkg:/exist/data/expathrepo/.expath-pkg</volume>
<volume>${project.build.outputDirectory}/icon.png:/exist/data/expathrepo/semver-xq-${project.version}/icon.png</volume>
<volume>${project.build.directory}/expath-descriptors/cxan.xml:/exist/data/expathrepo/semver-xq-${project.version}/cxan.xml</volume>
<volume>${project.build.directory}/expath-descriptors/exist.xml:/exist/data/expathrepo/semver-xq-${project.version}/exist.xml</volume>
<volume>${project.build.directory}/expath-descriptors/expath-pkg.xml:/exist/data/expathrepo/semver-xq-${project.version}/expath-pkg.xml</volume>
<volume>${project.build.directory}/expath-descriptors/repo.xml:/exist/data/expathrepo/semver-xq-${project.version}/repo.xml</volume>
<volume>${project.basedir}/LICENSE:/exist/data/expathrepo/semver-xq-${project.version}/LICENSE</volume>
<volume>${project.basedir}/README.md:/exist/data/expathrepo/semver-xq-${project.version}/README.md</volume>
<volume>${project.basedir}/src/main/xquery:/exist/data/expathrepo/semver-xq-${project.version}/content</volume>
<volume>${project.build.directory}/3rd-party-xars:/exist/autodeploy</volume>
</bind>
</volumes>
<wait>
<log>Server has started, listening on</log>
<time>120000</time>
</wait>
<autoRemove>true</autoRemove>
</run>
</image>
</images>
</configuration>
<executions>
<execution>
<id>docker-semver-xq-start</id>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>docker-semver-xq-stop</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
I would note that if I remove the <autoRemove>true</autoRemove> then I no longer receive the exception, and it seems that the container is automatically removed when mvn -Pdev docker:stop is called anyway. So I am now a bit unsure as to the purpose of the autoRemove config option.
Info
- docker-maven-plugin version : 0.40.3
- Maven version (
mvn -v) :
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: /home/aretter/.sdkman/candidates/maven/current
Java version: 1.8.0_322, vendor: BellSoft, runtime: /home/aretter/.sdkman/candidates/java/8.0.322.fx-librca/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "5.13.0-52-generic", arch: "amd64", family: "unix"
- Docker version : Docker version 20.10.17, build 100c701
It's mentioned in the documentation
autoRemoveis an option fordocker:startand indicates that the container should be removed if it stops (on its own).docker:stopstops and removes the container, except when you specify akeepContainersoptions.
So in your case, you try to remove the containers twice because of the autoRemove. Removing the autoRemove part is the correct solution.
@rhuss Okay understood. I wonder if the situation could be improved in the Java code of the plugin though so that it just silently ignores it rather than throwing an exception.
Yes, that probably would make sense