Docker4drupal and ownership issue

In this post I explained how to use docker4drupal with Pantheon.
Everything works, but there was an annoiyng issue: I was not able to execute commands like drush dl or other commands that are executed inside the container.
This issue because, as explained, source code is mounted into the container and drush commands are execute inside the container, so that www-data user (inside the container) can't write host files, owned by my host user.

The solution is setfacl. This utility (installed by default un Ubuntu system) gives you a way to override permissions by chown.

So, when you set up your local environment you have to execute these two commands (thanks to Valerio Mulas for this solution):

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 in directories are writable by host user MYUSER and also from 82 user (the id of the www-data user inside the container).

I suggest to apply these configurations to the entire document root, so you can download modules, update core, etc.

Enjoy it!