I've created a little wrapper for execute drush commands inside the container:
docker-compose exec --user 82 php drush $@
This works but there is a problem: if I try do download a module (or update) with "drush dl", obviously docker can't write into modules/contrib directory, because www-data can't write on my host files.
Is there a different way than chown 82:82 contrib directory, from the host?
I've ran into the same permission issues on mac os (while using composer create-project).
I've solved it by building the php container from a custom Dockerfile, recreating the www-data user with the uid of the host user (usermod in not included in in the base image, so deluser and adduser will do the trick). Works fine for me now without using the --user arg for exec.
Dockerfile:
FROM wodby/drupal-php:7.0
RUN deluser www-data && addgroup -g 1000 -S www-data && adduser -u 1000 -D -S -G www-data www-data
docker-compose.yml:
services:
php:
build: .
....
Hope that helps :-)
I solved using "setfacl" command (on ubuntu):
sudo setfacl -Rm g:82:rwX,d:g:82:rwX path/to/dir
sudo setfacl -Rm g:MYUSER:rwX,d:g:MYUSER:rwX path/to/dir
In this way files chown is overridden by these values and my "host" user "MYUSER" and 82 user can write files.
PS: thanks to @vmulas for the solution
Also see ~http://docs.docker4drupal.org/en/latest/permissions/~ (new link below)
Most helpful comment
I solved using "setfacl" command (on ubuntu):
In this way files chown is overridden by these values and my "host" user "MYUSER" and 82 user can write files.
PS: thanks to @vmulas for the solution