docker icon indicating copy to clipboard operation
docker copied to clipboard

nginx: [alert] could not open error log file

Open Frantz-Renard opened this issue 2 years ago • 2 comments

Description

The template seems to have fundamental errors. When I use the exact same language and try to recreate the nginx and php containers only since I do not need a postgre nor a redis container, I always get the same nginx: [alert] that cannot open the error log in the wrong path. It should save it to "/var/logs/*". As a result my php container does not run and exits at (1) whenever I run docker compose.

Steps to reproduce

  1. Using the same example dockerfile example (without postgre & redis, only nginx and and php)
  2. replacing the volume paths to mount Screenshot 2024-04-01 at 3 38 37 PM Screenshot 2024-04-01 at 3 39 15 PM Screenshot 2024-04-01 at 3 39 35 PM Screenshot 2024-04-01 at 3 40 10 PM

Additional info

  • Craft version:
  • PHP version:
  • Database driver & version:
  • Plugins & versions:

Frantz-Renard avatar Apr 01 '24 19:04 Frantz-Renard

Hey @Frantz-Renard in line 32 you mount ./php/craft/html/index.php:/php/craft/htm/lindex.php is htm/lindex.php right?

jawys avatar Apr 23 '24 11:04 jawys

I'm not confident this will get resolved since the repo itself is deprecated, but the issue mentioned here is tied to this commit: https://github.com/craftcms/docker/commit/5a1018c2a4681c0b67adbd7c0c17edd7b71914ce

The issue itself is in the fact that the author of the commit CHOWN-ed a symlink and not the actual folder, which is: /var/log/nginx

Adding this to your Dockerfile should resolve the issue if somebody still has it:

RUN chown -R www-data:www-data /var/log/nginx

Alternative is:

chown -RL www-data:www-data /var/lib/nginx/

The -L flag enables following on symbolic links, which should also do the trick.

If you can confirm this, I will gladly do a PR on the image that still seems to be used. However, I would suggest checking out the new https://github.com/craftcms/image repository, which supports PHP 8.3 and 8.4.

vlaja avatar Mar 17 '25 21:03 vlaja