Docker www-data授予对var / www的写权限

时间:2017-10-13 10:34:57

标签: apache docker configuration

我正在运行一个php:7.0-apache Docker镜像,但我无权写入/var/www/html。如何向该用户授予写权限?

Dockerfile:

FROM php:7.0-apache

# PHP Extensions
RUN docker-php-ext-install pdo_mysql

# Composer
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
RUN php composer-setup.php
RUN php -r "unlink('composer-setup.php');"
RUN mv composer.phar /usr/local/bin/composer

ADD vhost-default.conf /etc/apache2/sites-enabled/000-default.conf

# Open Ports
EXPOSE 80
EXPOSE 443

主机会议

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /var/www/html >
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

1 个答案:

答案 0 :(得分:4)

要解决此问题,您需要在Dockerfile中添加额外的行,如:

RUN chown www-data:www-data /var/www/html/