How to deal with permissions using docker - nginx / php-fpm How to deal with permissions using docker - nginx / php-fpm docker docker

How to deal with permissions using docker - nginx / php-fpm


docker-compose.yml supports a user directive under services. The docs only mention it in the run command, but it works the same.

I have a similar setup and this is how I do it:

# file : docker-compose-prod.ymlversion: '2'services:  web:    image: "private/web"    ports:      - 80:80    volumes_from:      - php  php:    image: "private/php"    ports:      - 9000:9000    user: "$UID"

I have to run export UID before running docker-compose and then that sets the default user to my current user. This allows logging / caching etc. to work as expected.


I am using this solution "Docker for Symfony" https://github.com/StaffNowa/docker-symfony

New features on

./d4d start./d4s stop./d4d help


I've found a solution;But if someone can explain best practices, it will be appreciate !

Folders cache / logs / sessions from docker context where not empty (on host).
Now that folders have been flushed, Symfony creates them with good permissions.

I've found people using usermod to change UID, ie: 1000 for www-data / nginx ...But it seems to be an ugly hack. What do you think about ?