title: How to deal with permissions using docker - nginx / php-fpm
body: <p>I'm trying to deploy a very simple Symfony application using nginx &amp; php-fpm via Docker.</p>
  
  <p>Two docker services :<br>
  1. web : running nginx<br>
  2. php : running php-fpm; containing application source.</p>
  
  <p>I want to build images that can be deployed without any external dependency.
  That's why I'm copying source code within the <strong>php container</strong>.<br>
  On development process; i'm overriding <strong>/var/www/html</strong> volume with local path.</p>
  
  <pre><code># file: php-fpm/Dockerfile
  FROM php:7.1-fpm-alpine
  
  COPY ./vendor /var/www/html
  COPY . /var/www/html
  
  VOLUME /var/www/html
  </code></pre>
  
  <p>Now the docker-compose configuration file.</p>
  
  <pre><code># file : docker-compose-prod.yml
  version: '2'
  services:
    web:
      image: "private/web"
      ports:
        - 80:80
      volumes_from:
        - php
    php:
      image: "private/php"
      ports:
        - 9000:9000
  </code></pre>
  
  <p>The problem is about permissions.<br>
  When accessing localhost, Symfony is botting up, but <strong>cache</strong> / <strong>logs</strong> / <strong>sessions</strong> folders are not writable.</p>
  
  <ol>
  <li>nginx is using <strong>/var/www/html</strong> to serve static files.  </li>
  <li>php-fpm is using <strong>/var/www/html</strong> to execute php files.</li>
  </ol>
  
  <p>I'm not sure about the problem. 
  But how can I be sure about the following:</p>
  
  <ol>
  <li><strong>/var/www/html</strong> have to be readable for nginx ?  </li>
  <li><strong>/var/www/html</strong> have to be writable for php-fpm ?  </li>
  </ol>
  
  <p>Note: I'm building images from MacbookPro; <strong>cache / logs / sessions</strong> are 777.</p>