title: How to use composer with docker-compose?
body: <p>I am configuring the <code>docker-compose.yml</code> file and I want to run a PHP stack that contains Elastic, Redis, Symfony, and composer.</p>
  <p>Now the problem that I have is, that I don't know how can I use composer with docker because some features of composer need to have PHP and some extension. I don't want to build a new image and install Nginx and PHP and composer and extension of PHP on it, I won't to have all of them in a disparate image.</p>
  <p>What I have tried so far its this:</p>
  <pre><code>version : '2'
  
  services:
    nginx:
      image: tutum/nginx
      ports:
          - &quot;80:80&quot;
      volumes:        
          - ./nginx/default:/etc/nginx/sites-available/default
          - ./nginx/default:/etc/nginx/sites-enabled/default
          - ./logs/nginx-error.log:/var/log/nginx/error.log
          - ./logs/nginx-access.log:/var/log/nginx/access.log
          - ./app:/usr/share/nginx/html
  
    phpfpm:
        image: php:fpm
        ports:
            - 9000:9000
        volumes:      
            - ./app:/usr/share/nginx/html
            
    composer:
        image: composer/composer:php7
        command: install
        volumes: 
          - ./app:/app
  
    elastic2.4.4:
      image: elasticsearch:2.4.4    
      ports:
        - 9200:9200
      volumes:
        - ./esdata1:/usr/share/elasticsearch/data
  
    redis:
      image: redis:3.2
      ports:
        - 6379:6379
  </code></pre>
  <p>but this won't install dependencies.</p>