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.

  • Simple Docker image running Apache won't start up on Centos 7.2
  • Problems with --with-registry-auth option, doesnt work with AWS container repositories
  • Is Postgres designed to write to shared data stores?
  • Mesos-Marathon docker
  • What is the difference between docker Swarm and Swarm mode?
  • Unable to run rabbitmq using marathon mesos
  • I am running into some weird folder permission issues and I’m getting this error:
    error screenshot

    My Symfony can create a folder


    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:

        cache:        false

    Nothing had effect, so I’m lost here.

    Any ideas how to solve an issue?

  • Docker ERROR: Volume specifies nonexistent driver inmemory
  • TravisCI build succeeds even when tests fail
  • Running Docker using ConEmu
  • How to write parameterized Bash alias for Docker command
  • Docker OSX: Connect to a host port from a container
  • Where is the Docker daemon log on Ubuntu 14.04?
  • 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.