title: Composer install with separate docker container
body: <p>I would like to install composer container separately when docker setup. I found some similar answers.</p>
  <ul>
  <li>Most of them are installing composer inside a container <code>composer install</code> (Eg.  app container below code ). I think that is not cool!</li>
  <li>Some use <code>docker exec -it container_name /bin/bash composer install</code>. That is manually working process.</li>
  <li>Some use volume mount the whole application. Yeah, that is easy and working. But,It is not ok in production environments.</li>
  </ul>
  <p><strong>That's why I want to install composer container separately</strong></p>
  <p>Below are some parts of my codes</p>
  <pre><code>version: '3.8'
  
  services: 
    app:
      container_name: app
      build: 
        context: .
        dockerfile: ./docker/production/7.4/Dockerfile
      restart: unless-stopped
      volumes: 
        - ./docker/production/7.4/php/local.ini:/usr/local/etc/php/conf.d/local.ini  
      networks: 
        - app-network
      depends_on: 
        - composer       
  
    composer:
      container_name: composer
      user: &quot;${UID}:${GID}&quot;    
      image: composer
      command: /bin/bash &quot;/app/docker/production/7.4/start-composer.sh&quot;
      volumes: 
        - ./:/app:rw
      networks: 
        - app-network   
  
  </code></pre>
  <p>Here is start-composer.sh file</p>
  <pre><code>cd /app
  composer install --ignore-platform-reqs
  composer dump-autoload
  </code></pre>
  <p>I think I don't need to show <code>/docker/production/7.4/Dockerfile</code> file  because I don't want to use <code>composer install</code> directly inside that container</p>
  <p>when I run composer, it is installing outside directory, not in app container /var/www folder.</p>
  <p>So, how should I make composer container to be able to install automatically.</p>