Open tbouvet opened 8 years ago
There will be improvements for docker:stop
in 0.13.7 coming this week (see #87 and #333) which will stop all containers started with docker:start
from the same pom.xml (but not containers started by hand). This is done by attaching a label to the container with the Maven coordinates and docker:stop
will stop those containers even when called in an extra maven run. Up to now all containers created from the images configured in d-m-p are stopped.
But it seems that you have an issue that the container doesn't stop at all, which seems to be a different issue (because it should work). Could you post an example and/or some output of the Maven plugin ? Maybe with 0.13.7-SNAPSHOT which I just deployed on Maven central.
This is my pom.xml configuration:
<groupId>org.jolokia</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version> 0.13.6</version>
<configuration>
<dockerHost>tcp://${docker.host}:2376</dockerHost>
<certPath>${docker.certPath}</certPath>
<sourceDirectory>/</sourceDirectory>
<verbose>true</verbose>
<images>
<image>
<alias>organisation-training</alias>
<name>organisation/training</name>
<build>
<from>tomcat:7</from>
<assembly>
<basedir>/usr/local/tomcat</basedir>
<descriptor>assembly/docker.xml</descriptor>
</assembly>
<tags>
<tag>latest</tag>
<tag>${project.version}</tag>
</tags>
<env>
<CATALINA_OPTS>-Djava.security.egd=file:/dev/./urandom</CATALINA_OPTS>
</env>
<labels>
<label>dev</label>
</labels>
</build>
<run>
<ports>
<port>host.port:8080</port>
</ports>
<namingStrategy>alias</namingStrategy>
<wait>
<time>30000</time>
</wait>
<log>
<date>default</date>
</log>
</run>
</image>
</images>
</configuration>
<executions>
<execution>
<id>generate-docker-image</id>
<phase>package</phase>
<goals>
<goal>stop</goal>
<goal>build</goal>
<goal>start</goal>
</goals>
</execution>
And the log is
[INFO] --- docker-maven-plugin:0.13.6:stop (default-cli) @ training-web ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
I have tested with : mvn docker:stop
I have tested with 0.13.7-SNAPSHOT and I have the same problem.
i see that you're tagging the image w/ latest
and the ${project.version}
. when you start the container, what does docker ps
report as the image?
latest
interesting...
if you do a docker:start
and then docker:stop
against a container built today, is it properly stopped?
can you post the output of mvn -X docker:stop
from a run where it doesn't work? (i am guessing this is easily reproducible for you).
if I do a docker:start
and then docker:stop
against a container built today, it is not stopped.
Here are the logs. docker:start
[INFO] --- docker-maven-plugin:0.13.7-SNAPSHOT:start (default-cli) @ training-web ---
[INFO] DOCKER> [organisation/training] "organisation-training": Start container fd3e84fb514b
[INFO] DOCKER> [organisation/training] "organisation-training": Pausing for 30000 ms
docker:stop
[DEBUG] Goal: org.jolokia:docker-maven-plugin:0.13.7-SNAPSHOT:stop (default-cli)
[DEBUG] Style: Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<apiVersion>${docker.apiVersion}</apiVersion>
<autoPull default-value="on">${docker.autoPull}</autoPull>
<certPath>target/docker/cert</certPath>
<dockerHost>tcp://xx.xx.xx.xx:2376</dockerHost>
<image>${docker.image}</image>
<images>
<image>
<alias>organisation-training</alias>
<name>organisation/training</name>
<build>
<from>tomcat:7</from>
<assembly>
<basedir>/usr/local/tomcat</basedir>
<descriptor>assembly/docker.xml</descriptor>
</assembly>
<tags>
<tag>latest</tag>
<tag>1.0.0-SNAPSHOT</tag>
</tags>
<env>
<CATALINA_OPTS>-Djava.security.egd=file:/dev/./urandom</CATALINA_OPTS>
</env>
<labels>
<label>training-dev</label>
</labels>
</build>
<run>
<ports>
<port>host.port:8080</port>
</ports>
<namingStrategy>alias</namingStrategy>
<wait>
<time>30000</time>
</wait>
<log>
<date>default</date>
</log>
</run>
</image>
</images>
<keepContainer default-value="false">${docker.keepContainer}</keepContainer>
<keepRunning>${docker.keepRunning}</keepRunning>
<logDate>${docker.logDate}</logDate>
<logStdout default-value="false">${docker.logStdout}</logStdout>
<maxConnections default-value="100">${docker.maxConnections}</maxConnections>
<project default-value="${project}"/>
<registry>${docker.registry}</registry>
<removeVolumes>${docker.removeVolumes}</removeVolumes>
<settings default-value="${settings}"/>
<skip default-value="false">${docker.skip}</skip>
<useColor default-value="true">${docker.useColor}</useColor>
<verbose default-value="false">true</verbose>
</configuration>
[DEBUG] =======================================================================
[INFO]
[INFO] --- docker-maven-plugin:0.13.7-SNAPSHOT:stop (default-cli) @ training-web ---
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=1, ConflictMarker.markTime=0, ConflictMarker.nodeCount=282, ConflictIdSorter.graphTime=1, ConflictIdSorter.topsortTime=0, ConflictIdSorter.conflictIdCount=75, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=34, ConflictResolver.conflictItemCount=156, DefaultDependencyCollector.collectTime=1700, DefaultDependencyCollector.transformTime=36}
[DEBUG] org.jolokia:docker-maven-plugin:jar:0.13.7-20151203.084500-3:
[DEBUG] com.google.guava:guava:jar:18.0:compile
[DEBUG] org.apache.httpcomponents:httpclient:jar:4.3.6:compile
[DEBUG] org.apache.httpcomponents:httpcore:jar:4.3.3:compile
[DEBUG] commons-logging:commons-logging:jar:1.1.3:compile
[DEBUG] commons-codec:commons-codec:jar:1.6:compile
[DEBUG] com.github.jnr:jnr-unixsocket:jar:0.8:compile
[DEBUG] com.github.jnr:jnr-ffi:jar:2.0.3:compile
[DEBUG] com.github.jnr:jffi:jar:1.2.9:compile
[DEBUG] com.github.jnr:jffi:jar:native:1.2.9:runtime
[DEBUG] org.ow2.asm:asm:jar:5.0.3:compile
[DEBUG] org.ow2.asm:asm-commons:jar:5.0.3:compile
[DEBUG] org.ow2.asm:asm-analysis:jar:5.0.3:compile
[DEBUG] org.ow2.asm:asm-tree:jar:5.0.3:compile
[DEBUG] org.ow2.asm:asm-util:jar:5.0.3:compile
[DEBUG] com.github.jnr:jnr-x86asm:jar:1.0.2:compile
[DEBUG] com.github.jnr:jnr-constants:jar:0.8.7:compile
[DEBUG] com.github.jnr:jnr-enxio:jar:0.9:compile
[DEBUG] com.github.jnr:jnr-posix:jar:3.0.12:compile
[DEBUG] org.apache.commons:commons-lang3:jar:3.3.2:compile
[DEBUG] org.json:json:jar:20140107:compile
[DEBUG] org.fusesource.jansi:jansi:jar:1.11:compile
[DEBUG] org.bouncycastle:bcpkix-jdk15on:jar:1.51:compile
[DEBUG] org.bouncycastle:bcprov-jdk15on:jar:1.51:compile
[DEBUG] org.apache.maven.plugins:maven-assembly-plugin:jar:2.5.1:compile
[DEBUG] org.apache.maven:maven-plugin-api:jar:2.2.1:compile
[DEBUG] org.apache.maven:maven-core:jar:2.2.1:compile
[DEBUG] org.apache.maven:maven-settings:jar:2.2.1:compile
[DEBUG] org.apache.maven:maven-plugin-parameter-documenter:jar:2.2.1:compile
[DEBUG] org.slf4j:slf4j-jdk14:jar:1.5.6:runtime
[DEBUG] org.slf4j:slf4j-api:jar:1.5.6:runtime
[DEBUG] org.slf4j:jcl-over-slf4j:jar:1.5.6:runtime
[DEBUG] org.apache.maven.reporting:maven-reporting-api:jar:2.2.1:compile
[DEBUG] org.apache.maven.doxia:doxia-sink-api:jar:1.1:compile
[DEBUG] org.apache.maven.doxia:doxia-logging-api:jar:1.1:compile
[DEBUG] org.apache.maven:maven-profile:jar:2.2.1:compile
[DEBUG] org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile
[DEBUG] junit:junit:jar:3.8.1:compile
[DEBUG] org.apache.maven:maven-repository-metadata:jar:2.2.1:compile
[DEBUG] org.apache.maven:maven-error-diagnostics:jar:2.2.1:compile
[DEBUG] commons-cli:commons-cli:jar:1.2:compile
[DEBUG] org.apache.maven:maven-plugin-descriptor:jar:2.2.1:compile
[DEBUG] org.codehaus.plexus:plexus-interactivity-api:jar:1.0-alpha-4:compile
[DEBUG] org.apache.maven:maven-artifact-manager:jar:2.2.1:compile
[DEBUG] backport-util-concurrent:backport-util-concurrent:jar:3.1:compile
[DEBUG] org.apache.maven:maven-monitor:jar:2.2.1:compile
[DEBUG] classworlds:classworlds:jar:1.1:compile
[DEBUG] org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:compile
[DEBUG] org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[DEBUG] org.apache.maven:maven-project:jar:2.2.1:compile
[DEBUG] org.apache.maven:maven-plugin-registry:jar:2.2.1:compile
[DEBUG] org.apache.maven:maven-artifact:jar:2.2.1:compile
[DEBUG] org.apache.maven:maven-model:jar:2.2.1:compile
[DEBUG] org.apache.maven.shared:maven-common-artifact-filters:jar:1.4:compile
[DEBUG] org.codehaus.plexus:plexus-interpolation:jar:1.21:compile
[DEBUG] org.codehaus.plexus:plexus-archiver:jar:2.8.2:compile
[DEBUG] org.apache.commons:commons-compress:jar:1.9:compile
[DEBUG] org.apache.maven.shared:file-management:jar:1.1:compile
[DEBUG] org.apache.maven.shared:maven-shared-io:jar:1.1:compile
[DEBUG] org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-6:compile
[DEBUG] commons-io:commons-io:jar:2.2:compile
[DEBUG] org.apache.maven.shared:maven-filtering:jar:1.3:compile
[DEBUG] org.apache.maven.shared:maven-shared-utils:jar:0.6:compile
[DEBUG] com.google.code.findbugs:jsr305:jar:2.0.1:compile
[DEBUG] org.sonatype.plexus:plexus-build-api:jar:0.0.4:compile
[DEBUG] org.codehaus.plexus:plexus-io:jar:2.3.3:compile
[DEBUG] org.apache.maven:maven-archiver:jar:2.5:compile
[DEBUG] org.codehaus.plexus:plexus-utils:jar:3.0.20:compile
[DEBUG] org.apache.maven.shared:maven-repository-builder:jar:1.0-alpha-2:compile
[DEBUG] joda-time:joda-time:jar:2.8.2:compile
[DEBUG] Created new class realm plugin>org.jolokia:docker-maven-plugin:0.13.7-SNAPSHOT
[DEBUG] Importing foreign packages into class realm plugin>org.jolokia:docker-maven-plugin:0.13.7-SNAPSHOT
[DEBUG] Imported: < project>xxxx:training-web:1.0.0-SNAPSHOT
[DEBUG] Populating class realm plugin>org.jolokia:docker-maven-plugin:0.13.7-SNAPSHOT
[DEBUG] Included: org.jolokia:docker-maven-plugin:jar:0.13.7-SNAPSHOT
[DEBUG] Included: com.google.guava:guava:jar:18.0
[DEBUG] Included: org.apache.httpcomponents:httpclient:jar:4.3.6
[DEBUG] Included: org.apache.httpcomponents:httpcore:jar:4.3.3
[DEBUG] Included: commons-logging:commons-logging:jar:1.1.3
[DEBUG] Included: commons-codec:commons-codec:jar:1.6
[DEBUG] Included: com.github.jnr:jnr-unixsocket:jar:0.8
[DEBUG] Included: com.github.jnr:jnr-ffi:jar:2.0.3
[DEBUG] Included: com.github.jnr:jffi:jar:1.2.9
[DEBUG] Included: com.github.jnr:jffi:jar:native:1.2.9
[DEBUG] Included: org.ow2.asm:asm:jar:5.0.3
[DEBUG] Included: org.ow2.asm:asm-commons:jar:5.0.3
[DEBUG] Included: org.ow2.asm:asm-analysis:jar:5.0.3
[DEBUG] Included: org.ow2.asm:asm-tree:jar:5.0.3
[DEBUG] Included: org.ow2.asm:asm-util:jar:5.0.3
[DEBUG] Included: com.github.jnr:jnr-x86asm:jar:1.0.2
[DEBUG] Included: com.github.jnr:jnr-constants:jar:0.8.7
[DEBUG] Included: com.github.jnr:jnr-enxio:jar:0.9
[DEBUG] Included: com.github.jnr:jnr-posix:jar:3.0.12
[DEBUG] Included: org.apache.commons:commons-lang3:jar:3.3.2
[DEBUG] Included: org.json:json:jar:20140107
[DEBUG] Included: org.fusesource.jansi:jansi:jar:1.11
[DEBUG] Included: org.bouncycastle:bcpkix-jdk15on:jar:1.51
[DEBUG] Included: org.bouncycastle:bcprov-jdk15on:jar:1.51
[DEBUG] Included: org.apache.maven.plugins:maven-assembly-plugin:jar:2.5.1
[DEBUG] Included: org.slf4j:slf4j-jdk14:jar:1.5.6
[DEBUG] Included: org.slf4j:jcl-over-slf4j:jar:1.5.6
[DEBUG] Included: org.apache.maven.reporting:maven-reporting-api:jar:2.2.1
[DEBUG] Included: org.apache.maven.doxia:doxia-sink-api:jar:1.1
[DEBUG] Included: org.apache.maven.doxia:doxia-logging-api:jar:1.1
[DEBUG] Included: junit:junit:jar:3.8.1
[DEBUG] Included: commons-cli:commons-cli:jar:1.2
[DEBUG] Included: org.codehaus.plexus:plexus-interactivity-api:jar:1.0-alpha-4
[DEBUG] Included: backport-util-concurrent:backport-util-concurrent:jar:3.1
[DEBUG] Included: org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3
[DEBUG] Included: org.sonatype.plexus:plexus-cipher:jar:1.4
[DEBUG] Included: org.apache.maven.shared:maven-common-artifact-filters:jar:1.4
[DEBUG] Included: org.codehaus.plexus:plexus-interpolation:jar:1.21
[DEBUG] Included: org.codehaus.plexus:plexus-archiver:jar:2.8.2
[DEBUG] Included: org.apache.commons:commons-compress:jar:1.9
[DEBUG] Included: org.apache.maven.shared:file-management:jar:1.1
[DEBUG] Included: org.apache.maven.shared:maven-shared-io:jar:1.1
[DEBUG] Included: commons-io:commons-io:jar:2.2
[DEBUG] Included: org.apache.maven.shared:maven-filtering:jar:1.3
[DEBUG] Included: org.apache.maven.shared:maven-shared-utils:jar:0.6
[DEBUG] Included: com.google.code.findbugs:jsr305:jar:2.0.1
[DEBUG] Included: org.sonatype.plexus:plexus-build-api:jar:0.0.4
[DEBUG] Included: org.codehaus.plexus:plexus-io:jar:2.3.3
[DEBUG] Included: org.apache.maven:maven-archiver:jar:2.5
[DEBUG] Included: org.codehaus.plexus:plexus-utils:jar:3.0.20
[DEBUG] Included: org.apache.maven.shared:maven-repository-builder:jar:1.0-alpha-2
[DEBUG] Included: joda-time:joda-time:jar:2.8.2
[DEBUG] Configuring mojo org.jolokia:docker-maven-plugin:0.13.7-SNAPSHOT:stop from plugin realm ClassRealm[plugin>org.jolokia:docker-maven-plugin:0.13.7-SNAPSHOT, parent: sun.misc.Launcher$AppClassLoader@308f5944]
[DEBUG] Configuring mojo 'org.jolokia:docker-maven-plugin:0.13.7-SNAPSHOT:stop' with basic configurator -->
[DEBUG] (f) autoPull = on
[DEBUG] (f) certPath = target/docker/cert
[DEBUG] (f) dockerHost = tcp://xx.xx.xx.xx:2376
[DEBUG] (f) alias = organisation-training
[DEBUG] (f) name = organisation/training
[DEBUG] (f) from = tomcat:7
[DEBUG] (f) basedir = /usr/local/tomcat
[DEBUG] (f) descriptor = assembly/docker.xml
[DEBUG] (f) assembly = org.jolokia.docker.maven.config.AssemblyConfiguration@28183058
[DEBUG] (f) tags = [latest, 1.0.0-SNAPSHOT]
[DEBUG] (f) env = {CATALINA_OPTS=-Djava.security.egd=file:/dev/./urandom}
[DEBUG] (f) labels = {label=training-dev}
[DEBUG] (f) build = org.jolokia.docker.maven.config.BuildImageConfiguration@288f93ca
[DEBUG] (f) ports = [host.port:8080]
[DEBUG] (f) namingStrategy = alias
[DEBUG] (f) time = 30000
[DEBUG] (f) wait = org.jolokia.docker.maven.config.WaitConfiguration@39a87c1d
[DEBUG] (f) date = default
[DEBUG] (f) log = org.jolokia.docker.maven.config.LogConfiguration@48689eb9
[DEBUG] (f) run = org.jolokia.docker.maven.config.RunImageConfiguration@4c8ca8d2
[DEBUG] (f) images = [ImageConfiguration {name='organisation/training', alias='organisation-training'}]
[DEBUG] (f) keepContainer = false
[DEBUG] (f) logStdout = false
[DEBUG] (f) maxConnections = 100
[DEBUG] (f) project = MavenProject: xxx:training-web:1.0.0-SNAPSHOT @ training-web\pom.xml
[DEBUG] (f) settings = org.apache.maven.execution.SettingsAdapter@c9d8918
[DEBUG] (f) skip = false
[DEBUG] (f) useColor = true
[DEBUG] (f) verbose = true
[DEBUG] -- end configuration --
[DEBUG] CookieSpec selected: best-match
[DEBUG] Auth cache not set in the context
[DEBUG] Connection request: [route: {s}->https://xx.xx.xx.xx:2376][total kept alive: 0; route allocated: 0 of 100; total allocated: 0 of 20]
[DEBUG] Connection leased: [id: 0][route: {s}->https://xx.xx.xx.xx:2376][total kept alive: 0; route allocated: 1 of 100; total allocated: 1 of 20]
[DEBUG] Opening connection {s}->https://xx.xx.xx.xx:2376
[DEBUG] Connecting to /xx.xx.xx.xx:2376
[DEBUG] Connection established xx.xx.xx.xx:53749<->xx.xx.xx.xx:2376
[DEBUG] Executing request GET /v1.18/containers/json?limit=100 HTTP/1.1
[DEBUG] Target auth state: UNCHALLENGED
[DEBUG] Proxy auth state: UNCHALLENGED
[DEBUG] http-outgoing-0 >> GET /v1.18/containers/json?limit=100 HTTP/1.1
[DEBUG] http-outgoing-0 >> Accept: */*
[DEBUG] http-outgoing-0 >> Content-Type: application/json; charset=utf-8
[DEBUG] http-outgoing-0 >> Host: xx.xx.xx.xx:2376
[DEBUG] http-outgoing-0 >> Connection: Keep-Alive
[DEBUG] http-outgoing-0 >> User-Agent: Apache-HttpClient/4.3.6 (java 1.5)
[DEBUG] http-outgoing-0 >> Accept-Encoding: gzip,deflate
[DEBUG] http-outgoing-0 >> "GET /v1.18/containers/json?limit=100 HTTP/1.1[\r][\n]"
[DEBUG] http-outgoing-0 >> "Accept: */*[\r][\n]"
[DEBUG] http-outgoing-0 >> "Content-Type: application/json; charset=utf-8[\r][\n]"
[DEBUG] http-outgoing-0 >> "Host: xx.xx.xx.xx:2376[\r][\n]"
[DEBUG] http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
[DEBUG] http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.3.6 (java 1.5)[\r][\n]"
[DEBUG] http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
[DEBUG] http-outgoing-0 >> "[\r][\n]"
[DEBUG] http-outgoing-0 << "HTTP/1.1 200 OK[\r][\n]"
[DEBUG] http-outgoing-0 << "Content-Type: application/json[\r][\n]"
[DEBUG] http-outgoing-0 << "Date: Thu, 03 Dec 2015 14:48:48 GMT[\r][\n]"
[DEBUG] http-outgoing-0 << "Content-Length: 687[\r][\n]"
[DEBUG] http-outgoing-0 << "[\r][\n]"
[DEBUG] http-outgoing-0 << "[{"Command":"catalina.sh run","Created":1449154006,"Id":"fd3e84fb514be21825ffafb1cf63b57efa51f9e9f619ffd1787991d73eaf2031","Image":"organisation/training:latest","Labels":{"dmp.coordinates":"xxx:training-web:1.0.0-SNAPSHOT","label":"training-dev"},"Names":["/organisation-training"],"Ports":[{"IP":"0.0.0.0","PrivatePort":8080,"PublicPort":32769,"Type":"tcp"}],"Status":"Up 2 minutes"}[\n]"
[DEBUG] http-outgoing-0 << "]"
[DEBUG] http-outgoing-0 << HTTP/1.1 200 OK
[DEBUG] http-outgoing-0 << Content-Type: application/json
[DEBUG] http-outgoing-0 << Date: Thu, 03 Dec 2015 14:48:48 GMT
[DEBUG] http-outgoing-0 << Content-Length: 687
[DEBUG] Connection can be kept alive indefinitely
[DEBUG] Connection [id: 0][route: {s}->https://xx.xx.xx.xx:2376][state: CN=client] can be kept alive indefinitely
[DEBUG] Connection released: [id: 0][route: {s}->https://xx.xx.xx.xx:2376][state: CN=client][total kept alive: 1; route allocated: 1 of 100; total allocated: 1 of 20]
i feel like there should be more output for the stop
command
No sorry only this. Just after I have:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
ok - i have an idea...
can you try specifying a tag as part of the initial image name? either organisation/training:latest
or organisation/training:${project.version}
and remove whatever one you choose from the tags
section?
Very good ! You are right. Stop is ok now !
[INFO] --- docker-maven-plugin:0.13.7-SNAPSHOT:stop (default-cli) @ training-web ---
[INFO] DOCKER> [organisation/training:latest] "organisation-training": Stop and remove container f64ffafea187
great - i will have to take a look and see how to deal w/ this.
worst case is we can throw an error if the image name doesn't contain any kind of tag, best case is it can work under the configuration you specified.
Ok for the best case :smiley: Thank you again. If you want I test your future upgrade, contact me.
i'm actually going to re-open this b/c there is something to be done here...
I'm using this plugin for continuous integration (pre-integration-tests, tests and post-integration-tests). All is perfect for this step, thank you for this plugin. I now want to use it for continuous deploiement. So I need to stop a container in another step as docker:start. But it seems to be not ok. Container doesn't stop. I'm looking for the documentation and I see:
My different steps are:
The goal is to start a new container after each new build (and so stop and remove old container).
Any idea for this kind of execution please ?