使用Laravel&的权限被拒绝的错误码头工人 [英] Permission Denied Error using Laravel & Docker

查看:51
本文介绍了使用Laravel&的权限被拒绝的错误码头工人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个docker容器:Nginx和App.
该应用程序容器扩展了PHP-fpm,并具有我的Laravel代码.

I have two docker containers: Nginx and App.
The app container extends PHP-fpm and also has my Laravel Code.

在我的docker-compose.yml中,我正在做

version: '2'
services:
    nginx:
        build:
            context: ./nginx
            dockerfile: ./Dockerfile
        ports:
            - "80:80"
        links:
            - app
    app:
        build:
            context: ./app
            dockerfile: ./Dockerfile

在我的Nginx Dockerfile中,我正在做

In my Nginx Dockerfile i'm doing:

FROM nginx:latest
WORKDIR /var/www
ADD ./nginx.conf /etc/nginx/conf.d/default.conf
ADD . /var/www
EXPOSE 80

在我的App Dockerfile中,我正在做

In my App Dockerfile I'm doing:

FROM php:7-fpm
WORKDIR /var/www
RUN apt-get update && apt-get install -y libmcrypt-dev mysql-client && docker-php-ext-install mcrypt pdo_mysql
ADD . /var/www

成功运行docker-compose后,尝试使用localhost时出现以下错误

After successfully running docker-compose up, I have the following error when I try localhost

无法打开流或文件"/var/www/storage/logs/laravel.log":打开流失败:权限被拒绝

据我了解,该存储文件夹需要Web服务器可写.
我应该怎么做才能解决这个问题?

From my understanding, the storage folder needs to writable by the webserver.
What should I be doing to resolve this?

推荐答案

使Dockerfile如下所示-

Make your Dockerfile something as below -

FROM php:7-fpm
WORKDIR /var/www
RUN apt-get update && apt-get install -y libmcrypt-dev mysql-client && docker-php-ext-install mcrypt pdo_mysql
ADD . /var/www
RUN chown -R www-data:www-data /var/www

这使目录/var/wwwwww-data拥有,而www-dataphp-fpm的默认用户.

This makes directory /var/www owned by www-data which is the default user for php-fpm.

因为它是由用户www-data编译的.

Since it is compiled with user www-data.

参考-

https://github.com/docker-库/php/blob/57b41cfc2d1e07acab2e60d59a0cb19d83056fc1/7.0/jessie/fpm/Dockerfile

这篇关于使用Laravel&的权限被拒绝的错误码头工人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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