简体   繁体   English

Docker无法在OS X本地OS X中将资产文件夹作为Web服务器进程写入资产文件夹

[英]Docker cannot write to assets folder as web server process in Yii/PHP application locally OS X

appreciate if you could help me. 感谢您能帮助我。

I'm running docker VM in a MAC OS X and seems okay until i reach a permissions error when my app is trying to write files in the assets folder in the server: 我在MAC OS X中运行Docker VM,并且在我的应用程序尝试在服务器的资产文件夹中写入文件时遇到权限错误之前似乎还可以:

CAssetManager.basePath "/var/www/html/assets" is invalid. Please make sure the directory exists and is writable by the Web server process.

I ran ls -l in the docker container shell ($ docker exec container) and saw that my folder permissions are set to drwxrwxrwx 1000 staff assets . 我在docker容器外壳($ docker exec容器)中运行ls -l ,发现我的文件夹权限设置为drwxrwxrwx 1000 staff assets Following that, i tried to set it to www-data as i though it might work , so i ran usermod -u 1000 www-data . 之后,我尝试将其设置为www-data,尽管它可能会起作用,所以我运行了usermod -u 1000 www-data Now folder becomes: drwxrwxrwx www-data staff assets but the error persists. 现在文件夹变为: drwxrwxrwx www-data staff assets但错误仍然存​​在。

In the shell, I also tried to run chmod and chown commands but i get these errors: 在外壳程序中,我也尝试运行chmodchown命令,但出现以下错误:

chown: changing ownership of 'assets': Read-only file system

chmod: changing ownership of 'assets': Read-only file system

How can i enable my directory to be writable by the web server process in docker? 如何在Docker中通过Web服务器进程使目录可写?

UPDATE: 更新:

$ docker ps returns $ docker ps返回

在此处输入图片说明

$ docker info## Heading ## returns $ docker info## Heading ##返回

在此处输入图片说明

UPDATE 2: $ docker inspect returns http://pastebin.com/wM3tT51v 更新2: $ docker inspect返回http://pastebin.com/wM3tT51v

Looking at the docker inspect output 看码头检查输出

        "Mounts": [
        {
            "Source": "/Users/joelkoh/Sites/merrymaker/php-app",
            "Destination": "/var/www/html",
            "Mode": "ro",
            "RW": false,
            "Propagation": "rprivate"
        }
    ],

It looks like your directory is read only, I'm not familiar with elastic beanstalk, but you will need to change that volume so it isn't read only. 看来您的目录是只读的,我对弹性beantalk不熟悉,但是您将需要更改该卷,因此它不是只读的。

You might consider using http://docker-sync.io for mounting shares. 您可以考虑使用http://docker-sync.io来安装共享。 Since it is not mounting, but syncing, it solved the user permission-problems by mapping your desired uid/guid to the container https://github.com/EugenMayer/docker-sync/blob/master/example/docker-sync.yml#L47 由于不是挂载而是同步,它通过将所需的uid / guid映射到容器https://github.com/EugenMayer/docker-sync/blob/master/example/docker-sync来解决了用户权限问题。 yml#L47

This way you have a very performant share, but also, having a proper user mapping to never care about permission issues in the container ( for host-mounted folders ) 这样一来,您不仅拥有出色的共享能力,而且拥有正确的用户映射,从而不必担心容器中的权限问题(对于主机安装的文件夹)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM