title: Building common dependencies with docker-compose
body: <p>Assuming I have a set of images which depend on a common base image:</p>
  
  <ul>
  <li><p>base (this is only a set of common dependencies)</p>
  
  <pre class="lang-sh prettyprint-override"><code>FROM ubuntu:16.04
  
  ENV FOO 1
  </code></pre></li>
  <li><p>child1</p>
  
  <pre class="lang-sh prettyprint-override"><code>FROM mybaseimage  # where mybaseimage corresponds to base
  
  CMD ["bar1_command"]
  </code></pre></li>
  <li><p>child2</p>
  
  <pre class="lang-sh prettyprint-override"><code>FROM mybaseimage  # where mybaseimage corresponds to base
  
  CMD ["bar2_command"]
  </code></pre></li>
  </ul>
  
  <p>Is it possible to create <code>docker-compose</code> file which would build <code>base</code> without running it? Lets say I have following dependencies:</p>
  
  <pre><code>version: '2'
  services:
      child1:
          build: ./path-to-child1-dockerfile
  services:
      child2:
          build: ./path-to-child2-dockerfile
      depends_on:
          - child1
  </code></pre>
  
  <p>I would like <code>base</code> to be build even if it is not explicitly started. Is something like this even possible? Or should I simply use external Makefile to build dependencies?</p>
  
  <pre><code>build_base:
      docker build -t mybaseimage mybaseimage  
  
  build_all: build_base
      docker-compose build
  </code></pre>