title: Access to outside of context in Dockerfile
body: <p>In my Maven project I have following structure:</p>
  
  <pre><code>docker/
     docker-compose.yml
     A/
       Dockerfile
     B/
       Dockerfile
  src/
  target/
     foo.war
  </code></pre>
  
  <p>In A's Dockerfile I need access to war in <code>/target</code> folder with the following command:</p>
  
  <pre><code>COPY ../../target/foo.war /usr/local/tomcat/webapps/foo.war
  </code></pre>
  
  <p>when I run <code>docker-compose up</code> tt gives me error</p>
  
  <blockquote>
    <p>failed to build: COPY failed: Forbidden path outside the build
    context: ../../target/foo.war</p>
  </blockquote>
  
  <p>docker-compose.yml</p>
  
  <pre><code>version: '3.6'
  services:
    fooA:
      build: ./docker/A
      ports:
        - "8080:8080"
      depends_on:
        - fooB
  
    fooB:
      build: ./docker/fooB
      ports:
        - "5433:5433"
  </code></pre>
  
  <p>Can you tell me how to solve this? I don't want copy war file manually after every project build.</p>