我得到这个错误:
/run.sh: 3: cd: can't cd to /var/www
但是,当我运行一个交互式shell时,我可以看到我的当前目录是/var/www。
这是我的dockerfile:
FROM php:8.1.0-fpm
# Set working directory
WORKDIR /var/www
# Add docker php ext repo
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
# Install php extensions
RUN chmod +x /usr/local/bin/install-php-extensions && sync && \
install-php-extensions mbstring pdo_mysql zip exif pcntl gd memcached
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
locales \
zip \
jpegoptim optipng pngquant gifsicle \
unzip \
git \
curl \
lua-zlib-dev \
libmemcached-dev \
nginx
# Install supervisor
RUN apt-get install -y supervisor
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
# Copy code to /var/www
COPY --chown=www:www-data . /var/www
# add root to www group
RUN chmod -R ug+w /var/www/storage
# Copy nginx/php/supervisor configs
RUN cp docker/supervisor.conf /etc/supervisord.conf
RUN cp docker/php.ini /usr/local/etc/php/conf.d/app.ini
RUN cp docker/nginx.conf /etc/nginx/sites-enabled/default
# PHP Error Log Files
RUN mkdir /var/log/php
RUN touch /var/log/php/errors.log && chmod 777 /var/log/php/errors.log
# Deployment steps
RUN composer update
RUN composer install --optimize-autoloader --no-dev
RUN chmod +x /var/www/docker/run.sh
EXPOSE 80
COPY ./docker/run.sh /
ENTRYPOINT ["sh","/run.sh"]
这是我的www.example.com的内容run.sh:
#!/bin/sh
cd /var/www
php artisan cache:clear
php artisan route:cache
/usr/bin/supervisord -c /etc/supervisord.conf
正如你所看到的,我正在尝试运行一个php laravel应用程序。我不知道为什么会发生这种情况,我会很感激任何想法来解决这个问题。谢谢你
PD:这是www.example.com的权限run.sh,它位于我的laravelapp的docker/目录中:
ls -ldh /var/www/
输出:
drwxr-xr-x 1 root root 4.0K Jun 8 17:45 /var/www/
1条答案
按热度按时间von4xj4u1#
COPY --chown=www:www-data . /var/www
应该是COPY --chown=www:www. /var/www
对于chown标志,用户和组都应该是
www
。此外,在您的
RUN chown www:www-data /var/www
中,您的屏幕截图应该更新为与递归chowning一样,RUN chown -R www:www /var/www