title: Managing directory permissions across the host and Docker container environments
body: <p>I'm trying to use a stack built with Docker container to run a Symfony2 application (<a href="https://github.com/advancingu/SfDocker" rel="nofollow">SfDocker</a>). The stack consists of interlinked containers where ubuntu:14.04 is a base:</p>
  
  <ul>
  <li>mysql db </li>
  <li>nginx </li>
  <li>php-fpm</li>
  </ul>
  
  <p>The recurring problem that I'm facing is managing directory permission inside the container. When I mount a vloume from the host, e.g.</p>
  
  <pre><code>volumes:   
  - symfony-code:/var/www/app
  </code></pre>
  
  <p>The mounted directories will always be owned by <code>root</code> or an unidentified user (only user ID visible when running <code>ls -al</code>) inside the container.</p>
  
  <p>This, essentially, makes it impossible to access the application through the browser. Of course running <code>chown -R root:www-data</code> on public directories solves the problem, but as soon as I want to write to e.g. 'cache' directory as from the host (where the user is <code>ltarasiewicz</code>) I'd get <code>permission denied error</code>. On top of that, whenever an application running inside a container creates new directories (e.h. 'logs'), they again are owned by<code>root</code> and later inaccessible by the browser or my desktop user.</p>
  
  <p>So my question are:</p>
  
  <ol>
  <li>How I should manage permission accross the host and container
  environments (when I want to run commands on the container from both
  environments) ?</li>
  <li>Is it possible to configure Docker so that directories mounted as volumes receive specific ownership/permissions (e.g. 'root:www-data') automatically?</li>
  <li>Am I free to create new users and user groups inside my 'nginx' container built from the Ubuntu:14.04 image ?</li>
  </ol>