How do I change the umask of a shared docker volume?

Deadly 提交于 2019-12-10 20:21:37

问题


This is related to "https://stackoverflow.com/questions/36477636/how-do-i-implement-a-shared-hosting-like-service-with-docker".

I am trying to setup a bunch of apache-php containers that should be able to rw to the docroot, and one single sftp container that should also be able to rw to the same directory. So, the plan is to create a shared volume, and mount it inside both containers (obviously in different places when it comes to the sftp container). I modified the official php:7-apache launch script like so:

#!/bin/bash
set -e

### > My stuff
chmod g+s /var/www/html
chown -R :2048 /var/www/html
umask
umask 0002
umask
### < My stuff

# Apache gets grumpy about PID files pre-existing
rm -f /var/run/apache2/apache2.pid

exec apache2 -DFOREGROUND

and in fact the two umask lines confirm that the sandwiched umask 0002 runs correctly. However, when I bash into the container and test this myself, umask returns 022, and if I create any file, they in fact get permissions 644. I can then manually umask 0002 and any new file gets created with permissions 664 (and 775 for directories).

For this use case, it is critical that both containers (sftp and apache) can read and write in the shared volume. So, how do I go about this?

来源:https://stackoverflow.com/questions/36546147/how-do-i-change-the-umask-of-a-shared-docker-volume

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!