Folder permissions when running Symfony in Docker environment

I am running a Docker containers on OSX. Containers consist of:

  1. Symfony
  2. Nginx
  3. php-fpm
  4. Redis

This is a pretty common setup to run Symfony apps.

  • Docker push already in progress
  • CoreOS + Docker - Assign Containers a pool of routable IP's
  • When would I use `--interactive` without `--tty` in a Docker container?
  • Docker MySQL ERROR 1049 (42000): Unknown database 'users'
  • at command inside docker container
  • Unable to run docker node.js application
  • I am running into some weird folder permission issues and I’m getting this error:
    error screenshot

    My Symfony can create a folder

    /var/www/var/chache 
    

    but then it can’t write into it.
    Once cache folder created, folder permissions are set to this:

    10344 drwxr-xr-x 1 1000 staff    68 Apr 15 00:33 cache
    

    Owner of the folder is my local OSX user, which Docker is running under.
    I’ve tried to change folder permissions or owner from Symfony’s CLI in Docker and it has no effect.
    I tried to chmod -R 777 under my local console, permissions are changed, but then Symfony creates folder inside cache folder and can’t write into it again.

    I’ve also tried to disable caching in app_dev.php:

    $kernel = new AppKernel('dev', true); 
    // $kernel->loadClassCache();
    $request = Request::createFromGlobals();
    

    And in config.yml:

    twig:
        cache:        false
    

    Nothing had effect, so I’m lost here.

    Any ideas how to solve an issue?

  • docker swarm: How to inspect ingress-endpoint container
  • ELF Header or installation issue with bcrypt in Docker container
  • disable firewalld/iptables in centos7 minimal version
  • Can I use a Github repository as the source of a Docker image?
  • Docker and Namespace-related errors after a successful login to Bluemix
  • Getting logs of tomcat containers running in kubernetes pods using fluentd, elsasticsearch and kibana
  • 2 Solutions collect form web for “Folder permissions when running Symfony in Docker environment”

    You have not shown you Dockerfile, because of that I can give you an example of container with PHP-FPM where this problem is fixed:

    This row is fixing permission error: usermod -u 1000 www-data

    FROM debian:jessie  
    RUN apt-get update
    RUN apt-get install -y curl \
                           mcrypt \
        && apt-get install -y php5 \
                           php5-fpm \
                           php5-cli \
                           php-pear \
                           php5-common \
                           php5-igbinary \
                           php5-json \
                           php5-mysql \
                           php5-mysqlnd \
                           php5-gd \
                           php5-curl \
                           php5-dev \
                           php5-sqlite \
                           php5-memcached \
                           php5-memcache \
        && usermod -u 1000 www-data
    
    EXPOSE 9000
    

    check the official documentation here.

    I’m on ubuntu and to solve permissions problems I execute this commands:

    $ sudo setfacl -R -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs
    $ sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.