泊坞窗PHP:5.6安装的Apache开发环境体积缺少权限 [英] Docker php:5.6-Apache Development Environment missing permissions on volume mount

查看:200
本文介绍了泊坞窗PHP:5.6安装的Apache开发环境体积缺少权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个PHP组成的开发环境:5.6 apache的形象,一个mysql形象,卷装入包含该网站将位于/ var / www / html等/。卷安装有上有十月CMS。

I am attempting to create a development environment composed of a php:5.6-apache image, a mysql image, and a volume mount containing the website that will be located in /var/www/html/. The volume mount has has October CMS on it.

我需要的泊坞窗的用户有过卷的权限安装,但我不希望它是卷的所有者,所以我可以很容易地修改它的容器外,并立即看到我的修改。

I need the docker user to have permissions over the volume mount, but I do not want it to be the owner of that volume, so i can easily modify it outside of the container, and see my modifications immediately.

我的搬运工文件如下:

FROM php:5.6-apache
MAINTAINER me <me@internet>

# Install modules
RUN apt-get update
RUN apt-get -f install -y
RUN apt-get install -y wget
RUN apt-get update && apt-get install -y \
    libmcrypt-dev \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libmcrypt-dev \
    libpng12-dev \
    php-apc
RUN docker-php-ext-install mbstring mysql mcrypt pdo pdo_mysql zip
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/

RUN docker-php-ext-install gd

WORKDIR /var/www/html/

VOLUME /var/www/html/

RUN a2enmod rewrite

RUN usermod -a -G www-data root

RUN php5enmod mcrypt && service apache2 restart

我的码头工人,撰写包含MySQL数据库环境变量。

My Docker-compose contains environment variables for the MySql database.

当我运行它原样,我只是得到500错误,但如果我更改音量到www数据的所有权,该网站上来就好了。

When I run it as is, I just get 500 error, but if I change the ownership of the volume to www-data, the site comes up just fine.

我一直在使用环境变量来更改Apache用户和组为root试过,但没有奏效。

I have tried using environment variables to change the Apache user and group to root, but it did not work.

任何建议都大大AP preciated。

Any suggestions are greatly appreciated.

更新:我无法找到一个解决方案,在我寻找的方式解决了这一问题,并在年底实现的东西我认为随着越来越多的黑客攻击的。我添加了以下行dockerfile:

UPDATE: I was unable to find a solution that fixed the problem in the exact way I am looking for, and in the end implemented something I view as more of a hack. I added the following lines to the dockerfile:

RUN usermod -u 1000 www-data
RUN groupmod -g 1000 www-data

这些行更改用户和组的泊坞窗内相匹配的主人,这样,它完全访问权限。

These lines change the user and group inside the docker to match the owner, thus giving it complete access.

要知道,虽然也有一些情况下,你的系统将无法识别你作为用户1000和1000组如果不工作时,bash到泊坞窗apache的容器,检查哪些卷具有作为用户ID和组ID ,然后更改相应上方的线条。

Be aware though that there are some cases your system will not recognize you as user 1000 and group 1000. If this does not work, bash into the docker apache container, and check what the volume has as the user id and group id, and then change the lines above accordingly.

推荐答案

在运行后泊坞窗机启动默认你需要ssh到它,并运行了以下以上充分工作:

After you run docker-machine start default you need to ssh into it and run the following for the above to fully work:

须藤的mkdir --parents的/ var / www / html等
[假设在/ var / www / html等是在你的VirtualBox的共享文件夹]

sudo mkdir --parents /var/www/html [assuming that /var/www/html is the shared folder in your virtualbox]

sudo的安装-t vboxsf -o UID = 1000,GID = 1000无功/ www / html等的/ var / www / html等
[这是为了确保UID和GID是1000的下一部分工作]

sudo mount -t vboxsf -o uid=1000,gid=1000 var/www/html /var/www/html [this is to make sure the uid and gid is 1000 for the next part to work]

这篇关于泊坞窗PHP:5.6安装的Apache开发环境体积缺少权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆