php Docker -无法运行管理程序

q1qsirdb  于 2023-02-18  发布在  PHP
关注(0)|答案(2)|浏览(143)

我尝试在运行php8.1和laravel 9的本地Docker容器上安装Supervisor,但出现以下错误:

'PermissionError: [Errno 13] Permission denied: '/var/log/supervisor/supervisord.log'

这是我的配置:supervisor.conf

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/artisan queue:work
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
numprocs=1
redirect_stderr=true
stdout_logfile=/var/www/html/storage/logs/worker.log
stopwaitsecs=3600
stdout_logfile_maxbytes=5MB

php文档:

FROM php:8.1.13-fpm

RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libpng-dev \
        nano \
        libxslt1.1 \
        libxslt1-dev \
        unzip \
        git \
        gnupg \
        libpq-dev \
        libzip-dev \
        iputils-ping \
        supervisor \
    && docker-php-ext-install zip \
    gd \
    mysqli pdo pdo_mysql  \
    && docker-php-ext-enable pdo_mysql \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-configure intl \
    
RUN echo "memory_limit='512M'" >> /usr/local/etc/php/conf.d/php-extra.ini;

ENV PHP_IDE_CONFIG "serverName=new_app"

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer --version=2.3.8 && chmod +x /usr/bin/composer

# Set timezone
RUN rm /etc/localtime \
    && ln -s /usr/share/zoneinfo/Europe/Warsaw /etc/localtime \
    && "date" \
    && printf '[PHP]\ndate.timezone = "Europe/Warsaw"\n' > /usr/local/etc/php/conf.d/tzone.ini \

RUN usermod -aG docker $USER
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]

WORKDIR /var/www/html

我该怎么修呢?
问候。

cgh8pdjw

cgh8pdjw1#

问题是,您的Supervisor无权访问日志路径。
将其添加到您的Docker文件中COPY supervisord.conf ...命令的下方:

RUN chmod -R 766 /var/log/supervisor/supervisord.log
oyxsuwqo

oyxsuwqo2#

1.

我在你的文件夹里看到了你的文件不匹配

COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]

我建议修改如下:

COPY supervisord.conf /etc/supervisor/supervisord.conf
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]

2.

将此代码添加到您的dockerfile中,以替换原始行,然后重试。祝您好运

RUN usermod -aG docker $USER &&\
    mkdir -p /var/www/html/storage/logs &&\
    touch /var/www/html/storage/logs/worker.log

相关问题