title: How to run composer as non root user on official docker php image
body: <p>I am using the official php:alpine <a href="https://github.com/docker-library/php/blob/master/7.2/alpine3.7/fpm/Dockerfile" rel="noreferrer">https://github.com/docker-library/php/blob/master/7.2/alpine3.7/fpm/Dockerfile</a> as my base image. My projects are basically composer based project. So I installed composer on it like below. </p>
  
  <pre><code>RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin -- --filename=composer
  </code></pre>
  
  <p>When I install any packages using <code>composer install</code> it runs as root as the main php process runs as root. So how can I run main php process as root and composer as another non root user <code>deploy</code>? </p>
  
  <p><strong>Update-1</strong> 
  My dockerfile is like below. So as you can see I am not installing composer packages inside dockerfile rather I install those packages on <strong>container</strong> like <code>docker exec -it php composer install</code>. </p>
  
  <pre><code>FROM php:7.2-fpm-alpine
  ..........................
  ..........................
  ..........................
  RUN  set ex \
    # Install Composer( Requires git )
    &amp;&amp; curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin -- --filename=composer \
    ENTRYPOINT ["/entrypoint.sh"]
    CMD ["php-fpm"]
  </code></pre>
  
  <p>I was trying to achieve it like <a href="https://unix.stackexchange.com/questions/476155/how-to-pass-multiple-parameters-to-su-user-c-command">https://unix.stackexchange.com/questions/476155/how-to-pass-multiple-parameters-to-su-user-c-command</a> but in vain.</p>