Docker php:5.6-Apache Development Environment missing permissions on volume mount
<p>I am attempting to create a development environment composed of a php:5.6-apache image, a mysql image, and a volume mount containing the website that will be located in /var/www/html/.  The volume mount has has October CMS on it.  </p>

<p>I need the docker user to have permissions over the volume mount, but I do not want it to be the owner of that volume, so i can easily modify it outside of the container, and see my modifications immediately. </p>

<p>My docker file is as follows:</p>

<pre><code>FROM php:5.6-apache
MAINTAINER me &lt;me@internet&gt;

# Install modules
RUN apt-get update
RUN apt-get -f install -y
RUN apt-get install -y wget
RUN apt-get update &amp;&amp; apt-get install -y \
    libmcrypt-dev \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libmcrypt-dev \
    libpng12-dev \
    php-apc
RUN docker-php-ext-install mbstring mysql mcrypt pdo pdo_mysql zip
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/

RUN docker-php-ext-install gd

WORKDIR /var/www/html/

VOLUME /var/www/html/

RUN a2enmod rewrite

RUN usermod -a -G www-data root

RUN php5enmod mcrypt &amp;&amp; service apache2 restart
</code></pre>

<p>My Docker-compose contains environment variables for the MySql database.</p>

<p>When I run it as is, I just get 500 error, but if I change the ownership of the volume to www-data, the site comes up just fine.</p>

<p>I have tried using environment variables to change the Apache user and group to root, but it did not work.</p>

<p>Any suggestions are greatly appreciated.</p>

<p>UPDATE: I was unable to find a solution that fixed the problem in the exact way I am looking for, and in the end implemented something I view as more of a hack.  I added the following lines to the dockerfile:</p>

<pre><code>RUN usermod -u 1000 www-data
RUN groupmod -g 1000 www-data
</code></pre>

<p>These lines change the user and group inside the docker to match the owner, thus giving it complete access.  </p>

<p>Be aware though that there are some cases your system will not recognize you as user 1000 and group 1000.  If this does not work, bash into the docker apache container, and check what the volume has as the user id and group id, and then change the lines above accordingly.</p>