允许Web服务器编辑docker容器内的文件

I'm trying to setup docker as web developer environment on my mac. I share local volume from my machine to web root folder inside a container. But I got stuck with permissions, web-server inside docker can't create a new folder or write new files to shared volume because almost all files have permissions 744 and different a user and a group.

  • I thought make all permissions 777 but it doesn't sounds good because in the git and in future on a server it will be also with bad permissions. In any way, a new files and folder that is creating web-server have wrong permissions.
  • I thought make a same group name on my mac that running web server inside docker (www-data) and change permissions to 774. But it sounds stupid.

What is a best way to fast manage files inside a docker? In my way I need to edit PHP files and immediately see result in browser.

you can use docker exec -it container_id script script being either a sed or a replacement of your file with a new version.

Starting with docker 1.8, you can add a specific user, docker exec -u muyser