title: Maven run docker image with java ee application
body: <p>I have a running java ee application which is using wildfly and mysql. Now i heard that docker is using everyone and it is very productive so i decided to dockerize my development environment. Sounds easier than it is.</p>
  
  <p>What i have so far:</p>
  
  <ul>
  <li>Maven for packaging my app into a .war file</li>
  <li>Arquillian unit tests which runs the test on my locally installed wildfly instance</li>
  </ul>
  
  <p>What i want:</p>
  
  <ul>
  <li>Using predefined docker images (jboss/wildfly,...) for running my application.</li>
  <li>Also running my tests in the docker container.</li>
  </ul>
  
  <p>I started out by building an docker image with the maven-docker-plugin:</p>
  
  <pre><code>&lt;plugin&gt;
     &lt;groupId&gt;com.spotify&lt;/groupId&gt;
     &lt;artifactId&gt;docker-maven-plugin&lt;/artifactId&gt;
     &lt;version&gt;0.4.13&lt;/version&gt;
     &lt;configuration&gt;
        &lt;imageName&gt;netbeans/sampleapplication&lt;/imageName&gt;
        &lt;dockerDirectory&gt;src/main/docker&lt;/dockerDirectory&gt;
        &lt;resources&gt;
           &lt;resource&gt;
              &lt;targetPath&gt;/&lt;/targetPath&gt;
              &lt;directory&gt;${project.build.directory}&lt;/directory&gt;
              &lt;include&gt;${project.build.finalName}.war&lt;/include&gt;
           &lt;/resource&gt;
        &lt;/resources&gt;
        &lt;execution&gt;
           &lt;id&gt;build-image&lt;/id&gt;
           &lt;phase&gt;package&lt;/phase&gt;
           &lt;goals&gt;
              &lt;goal&gt;build&lt;/goal&gt;
           &lt;/goals&gt;
        &lt;/execution&gt;
     &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>Dockerfile:</p>
  
  <pre><code>FROM jboss/wildfly
  COPY *.war /opt/jboss/wildfly/standalone/deployments/app.war
  EXPOSE 8080 9990
  </code></pre>
  
  <p>Maven command: <code>clean package docker:build</code>.
  I can reach the application server just with my docker-maschine url and not like previously with localhost.
  In the end i just want to use a single maven command for:</p>
  
  <ol>
  <li>Building the application</li>
  <li>Building the docker images (wildfly,mysql...)</li>
  <li>Run arquillian junit tests</li>
  <li>Deploy the application and expose it via localhost:8080</li>
  <li>Stop container if a new deploy is made</li>
  </ol>
  
  <p>I am really struggling with that. Anbody an idea how to do this? </p>