title: Docker Compose - Run java web application (war file) on tomcat using volumes
body: <p>I try to deploy a java web application using maven and tomcat on docker. I am using two Dockerfiles, one for my maven project and one for tomcat composing them with docker-compose and then i copy the .war file from the maven container to the tomcat container but with a way i dont really like. Im sure that there is a way to do it with volumes and thats my question. My files are these...</p>
  
  <p>maven Dockerfile</p>
  
  <pre><code>FROM maven:3.5.2-jdk-8
  
  RUN git clone mygitproject
  
  # Create app directory
  WORKDIR mics-project
  
  RUN mvn install
  </code></pre>
  
  <p>tomcat Dockerfile_tc</p>
  
  <pre><code>FROM tomcat:8.0-jre8
  
  # Create app directory
  WORKDIR /usr/local/tomcat/bin
  
  CMD ["catalina.sh", "run"]
  
  EXPOSE 8080
  </code></pre>
  
  <p>docker-compose.yml</p>
  
  <pre><code>version: '3'
  services:
      maven:
          container_name: maven-container
          build:
              context: .
              dockerfile: Dockerfile
  
      tomcat:
          container_name: tomcat-container
          build:
              context: .
              dockerfile: Dockerfile_tc
          ports:
             - "8080:8080"
  </code></pre>
  
  <p>And then i have a .bat file and im running some commands to copy my war file to tomcat...</p>
  
  <pre><code>cd C:\Users\Administrator\Project\mics-project
  
  del "mics-project.war" &gt;nul 2&gt;&amp;1
  
  start docker cp maven-container:/mics-project/target/mics-project.war c:/Users/Administrator/Project/mics-project
  
  start docker cp c:/Users/Administrator/Project/mics-project/mics-project.war tomcat-container:/usr/local/tomcat/webapps/
  </code></pre>
  
  <p>It works! But how can i use volumes in my docker-compose.yml file instead of executing these commands?</p>