title: Docker: docker-compose copy files from container to host
body: <p>I want to copy all files during the installation process in <code>docker-compose.yml</code> file.</p>
  
  <p>If I run:</p>
  
  <pre><code>$ git clone https://github.com/laravel/laravel.git laravel-app
  $ cd laravel-app
  $ docker run --rm -v $(pwd):/app composer install
  </code></pre>
  
  <p>It will copy all new files from container to host during the installation process in the docker container.</p>
  
  <p>So I will see new <code>vendor</code> folder and <code>composer.lock</code> file in my <code>laravel-app</code> directory after installation.</p>
  
  <hr>
  
  <p>But if I setup volume in <code>docker-compose.yml</code>:</p>
  
  <pre><code>version: '3'
  services:
  
    #PHP Service
    app:
      build:
        context: .
        dockerfile: Dockerfile
      container_name: app
      restart: unless-stopped
      tty: true
      environment:
        SERVICE_NAME: app
        SERVICE_TAGS: dev
      working_dir: /var/www
      volumes:
        - ./:/var/www
        - ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
      networks:
        - app-network
  </code></pre>
  
  <p>And then setup installation process in <code>Dockerfile</code>:</p>
  
  <pre><code>FROM php:7.4.4-fpm
  
  # Set working directory
  WORKDIR /var/www
  
  # Install dependencies
  RUN apt-get update &amp;&amp; apt-get install -y
  
  # Install composer
  RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
  
  # Copy existing application directory contents
  COPY . /var/www
  
  # Install composer.json dependencies
  RUN composer install # &lt;&lt;-- !this one!
  </code></pre>
  
  <p>It will not copy <code>vendor</code> folder and <code>composer.lock</code> file back to my host.</p>
  
  <p>Hot to make it happen?</p>