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.

  • Version increment for docker images
  • Docker MEAN stack which FROM to use?
  • Update docker version where containers are running
  • Calling docker commands from jenkins job as step running outside docker VM
  • Met “/bin/bash: no such file” when building docker image from scratch
  • What are the best practices to deploy and host artifacts for a Docker Multicontainer environment in Elasticbeanstalk for Scala Apps?
  • 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?

  • Running Rails App in Docker Container using Non-Default Port
  • How to create env-file in centos 7 for docker
  • Docker, Nginx and PHP7: ERROR 111 Connection refused while connecting to upstream
  • How to tell docker worker node belong to which swarm?
  • How can I edit files in a docker container when it's down/not-started
  • Running non-www stuff on an Elastic Beanstalk Docker container
  • 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.