Laravel & Docker: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied Laravel & Docker: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied docker docker

Laravel & Docker: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied


There are several options, what could be wrong:

  1. The storage link isn't properly set, you can read about it here, after launching app container, you should do php artisan storage:link to check whether proper link is there
  2. You don't have the proper right for the given folder, from default, logs folder should have www-data writable rights, you can check that by ssh to machine and the do ls -l on files in /var/www/html/[your laravel app], if not, add the proper rights by: chown -R www-data:www-data *
  3. Also related to file permissions: you can disable SELinux (but only in dev server, never do it on live) by cehcking the status: sestatus and then enforcing it to 0 by setenforce 0 (however on live server, it's better to leave SElinux running and try to disable the problem by chcon -R -t httpd_sys_rw_content_t [path to storage folder here]


if the above does not work when its added to your .env file the following will:

sudo chmod o+w ./storage/ -R

this will give others permissions without altering user and group permissions.


if you are using laravel sail, add following to your .env file

WWWGROUP=1000WWWUSER=1000