title: php app files permission after docker build
body: <p>I'm trying to build docker image with SuiteCRM using this Dockerfile:</p>
  
  <pre><code>FROM php:5.4-apache
  
  RUN a2enmod rewrite
  
  RUN apt-get update \
      &amp;&amp; apt-get install -y apt-utils \
      &amp;&amp; apt-get install -y libpng12-dev libjpeg-dev mercurial zip nano \
      &amp;&amp; docker-php-ext-configure gd --with-jpeg-dir=/usr/lib \
      &amp;&amp; docker-php-ext-install gd \
      &amp;&amp; docker-php-ext-install mysqli \
      &amp;&amp; docker-php-ext-install pdo_mysql \
      &amp;&amp; apt-get -y install re2c libmcrypt-dev \
      &amp;&amp; docker-php-ext-install mcrypt \
      &amp;&amp; apt-get -y install zlib1g-dev \
      &amp;&amp; docker-php-ext-install zip \
      &amp;&amp; apt-get purge --auto-remove -y zlib1g-dev \
      &amp;&amp; apt-get -y install libssl-dev libc-client2007e-dev libkrb5-dev \
      &amp;&amp; docker-php-ext-configure imap --with-imap-ssl --with-kerberos \
      &amp;&amp; docker-php-ext-install imap mbstring json \
      &amp;&amp; rm -rf /var/lib/apt/lists/*
  
  RUN curl -k -L -o suitecrm.zip "https://suitecrm.com/component/dropfiles/?task=frontfile.download&amp;id=35"
  RUN unzip -q suitecrm.zip -d /var/www/
  RUN rm suitecrm.zip
  RUN rm -rf /var/www/html &amp;&amp; mv /var/www/suitecrm-7.2.2-max /var/www/html
  RUN rm -rf /var/www/suitecrm-7.2.2-max
  RUN chown -R www-data:www-data /var/www/html
  RUN chmod -R 755 /var/www/html
  RUN chmod -R 775 cache custom modules themes data upload config_override.php
  
  EXPOSE 80
  CMD ["apache2-foreground"]
  </code></pre>
  
  <p>Then image built and ran I've got an errors:</p>
  
  <pre><code>Warning: include(include/MVC/preDispatch.php): failed to open stream: Permission denied in /var/www/html/index.php on line 42
  ...
  </code></pre>
  
  <p>File owner is www-data:www-data</p>
  
  <pre><code>$ docker exec -t suite_web_dev ls -la index.php
  -rwxr-xr-x 1 www-data www-data 2525 Mar  2 18:04 index.php
  $ docker exec -t suite_web_dev ls -la include/MVC/preDispatch.php
  -rwxr-xr-x 1 www-data www-data 2766 Mar  2 18:04 include/MVC/preDispatch.php
  </code></pre>
  
  <p>If I exclude form Dockerfile lines where it downloading App and changing files permissions, and call these commands after image start, everything works fine.</p>
  
  <pre><code>RUN curl -k -L -o ...
  ...
  RUN chmod -R 775 cache custom modules themes data upload config_override.php
  </code></pre>
  
  <p>What differens between changing permission at build and after run? What I need to do for build image with App code?</p>
  
  <p><strong>Upd:</strong>
  docker runs under boot2docker:
  Boot2Docker-cli version: v1.7.1
  Docker version 1.7.1</p>