title: Writable folder permissions in docker
body: <p>I have a docker setup with some websites for localhost. I use Smarty as my template engine and it requires to have a writable templates_c folder. Any idea how I can make this folder writable?</p>
  
  <p>The error is as following:</p>
  
  <pre><code>PHP Fatal error:  Smarty error: unable to write to $compile_dir 
  '/var/www/html/sitename.local/httpdocs/templates_c'. 
  Be sure $compile_dir is writable by the web server user. in 
  /var/www/html/sitename.local/httpdocs/libs/Smarty.class.php on 
  line 1093
  </code></pre>
  
  <p>I know this could be set manually with linux but I am looking for an automatic <strong><em>global</em></strong> solution since I have many websites who have this issue</p>
  
  <p>Also worth mentioning I am using a pretty clean docker-compose.yml</p>
  
  <pre><code>php56:
    build: .
    dockerfile: /etc/docker/dockerfile_php_56
    volumes:
      - ./sites:/var/www/html
      - ./etc/php:/usr/local/etc/php
      - ./etc/apache2/apache2.conf:/etc/apache2/conf-enabled/apache2.conf
      - ./etc/apache2/hosts.conf:/etc/apache2/sites-enabled/hosts.conf
    ports:
      - "80:80"
      - "8080:8080"
    links:
      - mysql
  
  
  mysql:
    image: mysql
    ports:
      - "3306:3306"
    environment:
      - MYSQL_ROOT_PASSWORD=MY_PASSWORD
      - MYSQL_DATABASE=YOUR_DATABASE_NAME
    volumes: 
      - ./etc/mysql:/docker-entrypoint-initdb.d
  </code></pre>
  
  <p>With a small dockerfile for basics:</p>
  
  <pre><code>FROM php:5.6-apache
  
  RUN /usr/local/bin/docker-php-ext-install mysqli mysql
  RUN    docker-php-ext-configure mysql --with-libdir=lib/x86_64-linux-gnu/ \
      &amp;&amp; docker-php-ext-install mysql
  RUN a2enmod rewrite
  </code></pre>
  
  <p><a href="https://github.com/wesleyd85/docker-php7-httpd-apache2-mysql" rel="noreferrer">https://github.com/wesleyd85/docker-php7-httpd-apache2-mysql</a> (but then with php 5.6)</p>