title: How to install PHP composer inside a docker container
body: <p>I try to work out a way to create a dev environment using docker and laravel.</p>
  
  <p>I have the following dockerfile:</p>
  
  <pre><code>FROM php:7.1.3-fpm
  
  RUN apt-get update &amp;&amp; apt-get install -y libmcrypt-dev \
      mysql-client libmagickwand-dev --no-install-recommends \
      &amp;&amp; pecl install imagick \
      &amp;&amp; docker-php-ext-enable imagick \
  &amp;&amp; docker-php-ext-install mcrypt pdo_mysql
  &amp;&amp; chmod -R o+rw laravel-master/bootstrap laravel-master/storage
  </code></pre>
  
  <p>Laravel requires composer to call composer dump-autoload when working with database migration. Therefore, I need composer inside the docker container. </p>
  
  <p>I tried:</p>
  
  <pre><code>RUN curl -sS https://getcomposer.org/installer | php -- \
  --install-dir=/usr/bin --filename=composer
  </code></pre>
  
  <p>But when I call </p>
  
  <pre><code>docker-compose up
  docker-compose exec app composer dump-autoload
  </code></pre>
  
  <p>It throws the following error:</p>
  
  <pre><code>rpc error: code = 13 desc = invalid header field value "oci runtime error: exec failed: container_linux.go:247: starting container process caused \"exec: \\\"composer\\\": executable file not found in $PATH\"\n"
  </code></pre>
  
  <p>I would be more than happy for advice how I can add composer to the PATH within my dockerfile or what else I can do to surpass this error. </p>
  
  <p>Thanks for your support.
  Also: <a href="https://github.com/andrelandgraf/laravel-docker" rel="noreferrer">this</a> is the gitub repository if you need to see the docker-compose.yml file or anything else.</p>