I'm struggling to synthesise how to correctly use the maven-failsafe and fabric8-maven plugins together.
I Want to run integration tests, but in the pre-integration-tests phase, start a docker container running a DB, and in the post-integration-phase stop the container.
Looking at the fabric8 docker-maven-plugin documentation, it states this is possible, but none of the examples seem to illustrate this.
Update #1:
This is the configuration that successfully worked for me:
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.15.9</version>
<executions>
<execution>
<id>start-neo4j</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-neo4j</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<images>
<image>
<alias>neo4j</alias>
<name>neo4j:2.3.2-enterprise</name>
<run>
<ports>
<port>7474</port>
</ports>
<wait>
<log>Starting...</log>
<time>20000</time>
</wait>
</run>
</image>
</images>
</configuration>
</plugin>
There are serveral examples for the docker-maven-plugin which show how the bindings work:
https://github.com/fabric8io/docker-maven-plugin/blob/master/samples/data-jolokia-demo/ contains various configurations variants for running integrations tests where in the pre-test phase a tomcat is fired up, the application deployed, the tests run, and then the tomcat teared down.
https://github.com/rhuss/docker-maven-sample is probably more interesting for you as it covers your use case with starting a Postgres db before the integration test (inclusive waiting until the DB is completely started). The binding is shown here :
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>build</goal>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
But I recommend to examine the pom.xml there in more details, since it has even more info e.g. for how to setup the wait section. Feel free to open issues in this project if something is still unclear.