title: Gitlab CI for MAVEN project with Docker Image
body: <p>I have project on java, where i have my tests. Now i have <code>.gitlab-ci.yml</code>:</p>
  
  <pre><code>image: maven:latest
  
  stages:
    - build
  
  build:
    stage: build
    script:
      - mvn test-compile compile
    tags:
      - mytag
    only:
      refs:
        - dev
  </code></pre>
  
  <p>Each time, when i am making commit in my repo, i am waiting a lot of time, when it will download all depencies. In docker we can use volume option. The question:
  Can i download and compile locally this project for creating of <code>.m2</code> directory, and can i use this directory in my <code>.gitlab-ci.yml</code>. If yes, can you help me how, because i have not found in internet examples according to it.</p>
  
  <p>I made changes in my <code>/etc/gitlab-runner/config.toml</code>:</p>
  
  <pre><code>  [runners.docker]
      tls_verify = false
      image = "maven:latest"
      privileged = true
      disable_entrypoint_overwrite = false
      oom_kill_disable = false
      disable_cache = false
      volumes = ["/cache","/M2/.m2:/root/.m2"]
      shm_size = 0
  </code></pre>
  
  <p><code>/M2/</code> is a dir, with gitlab-runner owner. But it does not help, how we can see:</p>
  
  <pre><code>Downloaded from central: https://repo.maven.apache.org/maven2/org/hamcrest/hamcrest-parent/1.3/hamcrest-parent-1.3.pom (2.0 kB at 20 kB/s)
  Downloading from atlas: https://dl.bintray.com/qameta/maven/org/seleniumhq/selenium/selenium-java/3.8.1/selenium-java-3.8.1.pom
  Downloading from nio: http://clojars.org/repo/org/seleniumhq/selenium/selenium-java/3.8.1/selenium-java-3.8.1.pom
  Downloading from central: https://repo.maven.apache.org/maven2/org/seleniumhq/selenium/selenium-java/3.8.1/selenium-java-3.8.1.pom
  Progress (1): 2.2/5.9 kB
  Progress (1): 5.0/5.9 kB
  Progress (1): 5.9 kB    
  </code></pre>