Docker4drupal: Drush and file permissions

Created on 3 Dec 2016  路  4Comments  路  Source: wodby/docker4drupal

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?

enhancement

Most helpful comment

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

All 4 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

suricactus picture suricactus  路  9Comments

quietone1 picture quietone1  路  10Comments

Vacilando picture Vacilando  路  7Comments

pulasthibandara picture pulasthibandara  路  6Comments

dcre picture dcre  路  6Comments