title: Docker compose with two files
body: <p>I have two <code>docker-compose.yml</code> files in separate folders.</p>
  
  <p>I'd like to run the two of them in the same command, in order for the services from both to be able to talk to each other.</p>
  
  <p>However, when I go to the lowest common path ancestor and try to run <code>docker-compose</code> with both files, here is what happens:</p>
  
  <pre><code>$ docker-compose -f ./api-folder/docker-compose.yml -f ./front-folder/docker-compose.yml up -d
  ERROR: build path /projects/front-folder/api either does not exist, is not accessible, or is not a valid URL.
  
  $ docker-compose -f ./front-folder/docker-compose.yml -f ./api-folder/docker-compose.yml up -d
  ERROR: build path /projects/api-folder/app either does not exist, is not accessible, or is not a valid URL.
  </code></pre>
  
  <p>Here are the two <code>docker-compose.yml</code> files:</p>
  
  <p><strong>/projects/front-folder/docker-compose.yml</strong></p>
  
  <pre><code>version: '2'
  
  services:
  
      app:
          restart: always
          build: ./app
          environment:
              NODE_ENV: 'dev'
          ports:
              - "4400:4400"
          volumes:
              - ./app:/usr/src/app
  
      nginx:
          restart: always
          build: ./nginx
          volumes:
              - ./logs:/usr/local/var/log/nginx
          links:
              - app
          ports:
              - "80:80"
  </code></pre>
  
  <p><strong>/projects/api-folder/docker-compose.yml</strong></p>
  
  <pre><code>version: '2'
  
  services:
  
      api:
          restart: always
          build: ./api
          expose:
              - "4600"
          volumes:
              - ./api:/usr/src/app
              - ./logs:/logs
  
      nginx:
          restart: always
          build: ./nginx
          volumes:
              - ./logs:/usr/local/var/log/nginx
          links:
              - api
          ports:
              - "81:80"
          networks:
              - hackerz
  </code></pre>
  
  <p>And the directory structure:</p>
  
  <pre><code>- /projects
      - /front-folder
          - /app
              Dockerfile
          - /nginx
              Dockerfile
          docker-compose.yml
      - /api-folder
          - /api
              Dockerfile
          - /nginx
              Dockerfile
          docker-compose.yml
  </code></pre>
  
  <p>I'm guessing the problem is with the <code>build</code> paths, but what I don't understand is:</p>
  
  <ul>
  <li>Why Docker insists on searching <code>build: ./api</code> in <code>/front-folder</code> or the other way around?</li>
  <li>How to circumvent this problem and be able to run both files together?</li>
  </ul>