title: Specify umask in Dockerfile
body: <p>I'm using Mac OS and recently I'm trying to set up a development environment with docker. Docker seems to be nice, but currently I'm facing the following problem:</p>
  
  <p><strong>PROBLEM:</strong></p>
  
  <p>Whenever PHP (in the docker container) is creating a folder with a subfolder, apache results in a 500-error. Apache-log: "... Can't create directory app/../../folder/subfolder/subsubfolder/"</p>
  
  <p>I assume that this is caused by the environment variable <strong>umask</strong>, because whenever a folder is created, it doesn't have write permission. Because of that subfolders can't be created and so on.  </p>
  
  <p>To test this out, I wrote a little test-script (umask-test.php):</p>
  
  <pre><code>$umask = umask(0);
  echo ("umask = $umask &lt;br&gt;");
  </code></pre>
  
  <p>And bingo! Every time I build and run the container and start the script via the browser, the result is:</p>
  
  <pre><code>umask = 18
  </code></pre>
  
  <p><strong>GOAL:</strong></p>
  
  <p>So I would like to have <strong>umask</strong> always to be set to <strong>000 (zero)</strong></p>
  
  <p>I figured out, the best place to set this variable would be the Dockerfile, so in the Dockerfile I stated the following:</p>
  
  <pre><code>FROM ubuntu:trusty
  ...
  ENV UMASK 0
  ...
  </code></pre>
  
  <p>Problem is, that this results in nothing:</p>
  
  <ul>
  <li>the test-script gives out 18 for umask</li>
  <li>folders are still created with the wrong permission</li>
  <li>subfolders can't be created.</li>
  </ul>
  
  <p><strong>QUESTIONS:</strong></p>
  
  <p>What am I doing wrong?</p>
  
  <p>How can umask in docker containers always be set to zero?</p>
  
  <p>How can I permit the apache-user (www-data) to create folders that always have write-permissions and in which subfolders can be created? </p>