Folder permissions when running Symfony in Docker environment
I am running a Docker containers on OSX. Containers consist of:
This is a pretty common setup to run Symfony apps.
I am running into some weird folder permission issues and I’m getting this error:
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:
twig: cache: false
Nothing had effect, so I’m lost here.
Any ideas how to solve an issue?
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