如何在开发时设置docker上的文件和目录权限
我正在用docker开发一个symfony应用程序。 我'共享一个主机卷,它应该包含我的项目,应该与Apache运行。
docker run -d -ti --name web -p 80:80 -v /Users/Matteo/Documents/em3:/var/www/html/applications ubuntu /bin/bash
作为一个基础镜像,我已经使用了ubuntu,我已经安装了apache和PHP7。 一切正常,但是当我进入我的docker时:
docker exec -it web /bin/bash root@85a23559d01b:/var/www/html/applications/auth# app/console cache:clear --env=dev [Symfony\Component\Filesystem\Exception\IOException] Failed to remove directory "/var/www/html/applications/auth/app/cache/de~/jms_serializer": .
这可能是因为目录权限?
root@85a23559d01b:/var/www/html/applications/auth/app# ls -al | grep cache drwxr-xr-x 1 1000 staff 374 Oct 30 21:50 cache
chmod
虽然没有改变,但是:
root@85a23559d01b:/var/www/html/applications/auth/app# chmod g+w cache root@85a23559d01b:/var/www/html/applications/auth/app# ls -al | grep cache drwxr-xr-x 1 1000 staff 374 Oct 30 21:50 cache
我想我错过了一些东西。 任何帮助,将不胜感激
正如symfony问题2600中所评论的那样
如果您在Windows主机上使用Linux VirtualBox,则可以“轻松”重现此操作。
[这可能就是这种情况,使用Docker Toolbox的 boot2docker
,而不是Docker for Windows及其Hyper-V]
cache:clear
是永远不能删除app/cache/dev_old
– 但这可能是由VirtualBox提供的共享文件夹系统(阅读有关他们的论坛上类似的问题)的问题。您必须升级VirtualBox Guest Additions
OP Bertuz 在评论中指出:“ 将boot2docker更改为在OS X中使用NFS进行本地安装 ”及其文件-nfs-mount-boot2docker-sh要点(以及更新版本 )。