Answer the question
In order to leave comments, you need to log in
How to pull PHP logs out of the container?
In php.ini, I specified where to write the logs, in the Dockerfile I create the necessary file, in docker-compose I mount the folder with it, but as a result, the log is not created and errors are not written anywhere. I suspect that by creating a file before mounting the volume, I lose it. How to do it right?
php.ini snippet:
error_reporting = E_ALL
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = On
report_memleaks = On
html_errors = Off
error_log = "/usr/local/php-logs/php-fpm.log"
FROM php:8.0-fpm
RUN mkdir -p /usr/local/php-logs && \
touch /usr/local/php-logs/php-fpm.log && \
chmod 666 /usr/local/php-logs/php-fpm.log
version: '3'
services:
#PHP
php:
build:
context: ./image/php8.0/.
image: analytics/php:8.0
container_name: analytics-php8.0
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: analytics
SERVICE_TAGS: prod
working_dir: /var/www
volumes:
- ./app:/var/www
- ./logs:/usr/local/php-logs
#Nginx Service
webserver:
build:
context: ./image/nginx/.
image: analytics/nginx
container_name: analytics-ngnx
restart: unless-stopped
tty: true
ports:
- "${HTTP_PORT}:80"
- "${HTTP_SECURE_PORT}:443"
volumes:
- ./app:/var/www
- ./logs:/var/log/nginx
Answer the question
In order to leave comments, you need to log in
The following advice from a like-minded person from another resource helped:
Since the entire directory where the volume is connected is replaced, you need to create a file after mounting using the CMD section:
CMD touch /usr/local/php-logs/php-fpm.log && \
chmod 666 /usr/local/php-logs/php-fpm.log && \
php-fpm -F
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question