我想创建一个Docker镜像来引导Symfony项目.这是我的Dockerfile:
FROM php:7-apache LABEL Description = "This image is used to start Symfony3 project" ENV DIRPATH /var/www/html # apt-get command RUN apt-get update && apt-get install -y \ vim \ git RUN apt-get install -y zlib1g-dev && docker-php-ext-install zip # Install Composer RUN curl -sS https://getcomposer.org/installer | php RUN mv composer.phar /usr/local/bin/composer # Install the Symfony Installer RUN curl -LsS http://symfony.com/installer -o /usr/local/bin/symfony RUN chmod a+x /usr/local/bin/symfony # Create the php.ini file RUN cp /usr/src/php/php.ini-development /usr/local/etc/php/php.ini
构建和容器创建工作正常,但我的容器中有权限问题.当我要去app_dev.php时,我收到了这条消息:
您无权访问此文件.检查app_dev.php以获取更多信息.
显然,我只能使用localhost访问此文件.此外,PHP无法在我的容器中删除或创建任何内容.例如,我在运行时遇到以下错误:
$php app/console cache:clear Failed to remove directory "/var/www/html/app/cache/dev_old/doctrine
我怎样才能在Dockerfile中解决这个问题?
终于在几周后找到了它:
在你的Dockerfile中添加它.它解决了许可问题.
# Workaround for write permission on write to MacOS X volumes # See https://github.com/boot2docker/boot2docker/pull/534 RUN usermod -u 1000 www-data