我创建了一个laravel项目并将其放在docker容器中,并且看起来一切正常,但是在某个时候,我收到一条错误消息:
There is no existing directory at "/Users/john/Documents/work/dashboard/src/storage/logs" and its not buildable: Permission denied
奇怪的是,Laravel试图写到属于我的本地环境的文件或目录中,而不是写入到我希望是这样的docker容器环境中:
/var/www/storage/logs
这是我的docker-compose.yml:
version: '2'
services:
# The Web Server
web:
build:
context: ./
dockerfile: web.signup.dockerfile
working_dir: /var/www
volumes:
- ./src:/var/www
- /var/www/storage
env_file: 'src/.env'
ports:
- 80:80
volumes:
dbdata:
这是我的Dockerfile
FROM centos:latest
RUN set -ex \
&& yum install -y epel-release \
&& yum update -y mysql-client libmagickwand-dev \
&& yum install -y libmcrypt-devel \
&& yum install -y python-pip \
&& pip install --upgrade pip \
&& yum install -y zip unzip \
&& yum install -y java-1.8.0-openjdk \
&& yum clean all
RUN pip install --upgrade --ignore-installed six awscli
RUN yum install -y supervisor
RUN yum install -y php-pear php-devel
RUN pecl install imagick
# Add the Ngix
ADD nginx.repo /etc/yum.repos.d/nginx.repo
# Add the Centos PHP dependent repository
RUN rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
RUN yum update -y
# Installing Nginx
RUN yum -y install nginx
# Installing PHP
RUN yum -y --enablerepo=remi,remi-php72 install php-fpm php-common php-mcrypt php-mbstring
WORKDIR /var/www
ADD vhost.prod.conf /etc/nginx/conf.d/default.conf
COPY src/. /var/www
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
&& php composer-setup.php \
&& php -r "unlink('composer-setup.php');" \
&& php composer.phar install --no-dev --no-scripts \
&& rm composer.phar
RUN chown -R apache:apache \
/var/www/storage \
/var/www/bootstrap/cache
EXPOSE 80
EXPOSE 9000
RUN mkdir -p /run/php-fpm
COPY supervisord.conf /supervisord.conf
CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"]
有什么想法吗?
答案 0 :(得分:1)
按设计工作,
您正在将当前目录中的“ src”挂载到容器中。
volumes:
- ./src:/var/www
如果要访问容器内的代码,可以在构建时添加文件。
要修复您的“错误”,
chmod -R 777 /Users/john/Documents/work/dashboard/src/storage/logs
适合当地的开发环境
答案 1 :(得分:0)
从我的角度来看,结果是无论我们在物理文件夹中更改了什么文件夹权限。
删除 bootstrap/cache/* 中的所有内容解决了问题。
答案 2 :(得分:0)
就我而言,当我用完硬盘空间并清除它时出现此错误 只有这样有帮助:
rm bootstrap/cache/config.php
php artisan cache:clear
composer dump-autoload