title: Running mvn clean install inside docker container using ansible playbook
body: <p>I am trying to run mvn clean install command inside the docker container. But nothing seems to happen as I have mapped my container to a volume and no target folder is created. This is the playbook. Apologies if this is a silly question but I have been stuck here for some frustating time now.</p>
  
  <pre><code>---
  - name: Building project
    hosts: all
    become: true
    become_user: root
    tasks:
       - name: install docker mvn
         docker_container:
            name: maven_build_direct
            image: maven
            volumes:
              - /home/user/Desktop/Training/docker/maven_task/happy/GsaJavaExample/:/proj
            command: cd /proj
            command: mvn clean install
  </code></pre>
  
  <p>I also tried running commands from outside the docker-container module but since the container already stops it gives error. Something like this</p>
  
  <pre><code>     - name: copy content in container to some other folder
         command: docker exec -i maven_build_direct bash -c 'echo "Hello1"; echo "Hello2"'
  </code></pre>
  
  <p>The error for the above is</p>
  
  <blockquote>
    <p>fatal: [localhost]: FAILED! => {"changed": true, "cmd": ["docker", "exec", "-i", "maven_build_direct", "bash", "-c", "echo \"Hello1\"; echo \"Hello2\""], "delta": "0:00:00.212534", "end": "2018-08-26 17:07:06.995110", "msg": "non-zero return code", "rc": 126, "start": "2018-08-26 17:07:06.782576", "stderr": "", "stderr_lines": [], "stdout": "OCI runtime exec failed: exec failed: cannot exec a container that has stopped: unknown", "stdout_lines": ["OCI runtime exec failed: exec failed: cannot exec a container that has stopped: unknown"]}</p>
  </blockquote>