如何在Docker映像中设置laravel文件权限

问题描述

我具有以下dockerfile来构建我的Laravel Web应用程序。运行它后,尝试访问供应商存储目录时出现权限错误。我的问题是为php:7.2-fpm基本映像设置Laravel权限的正确方法是什么。我收到的错误是:

打开(/var/www/app/vendor/dompdf/dompdf/lib/fonts/glyphicons-halflings-normal_4ced20531a4f462a8c5c535d4debd2eb.ufm): 打开流失败:权限被拒绝

Dockerfile

FROM php:7.2-fpm

WORKDIR /var/www/app

RUN apt-get update && apt-get install -y \
    build-essential \
    libpng-dev \
    libjpeg62-turbo-dev \
    libfreetype6-dev \
    locales \
    zip \
    jpegoptim optipng pngquant gifsicle \
    vim \
    unzip \
    git \
    curl \
    npm

RUN curl -sL https://deb.nodesource.com/setup_9.x | bash
RUN apt-get install -y nodejs 

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Install extensions
RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl
RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/
RUN docker-php-ext-install gd
RUN docker-php-ext-install bcmath

# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Copy existing application directory contents

COPY . /var/www/app

RUN chmod -R 775 /var/www/app
RUN chmod -R 775 /var/www/app/vendor
RUN chmod -R 777 /var/www/app/storage

# COPY --from=nodeBuild ./ /var/www
RUN composer install
RUN npm install
RUN npm update

# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)