There are a lot of articles about this, I read them but none of the solutions worked.
I have laravel mounted via docker-compose in the folder /var/www/html/app
I am using this docker image https://github.com/khromov/alpine-nginx-php8/blob/master/Dockerfile
Logged into the container as root user with docker-compose exec -u root web sh
, I can gave 777 permission to all under bootstrap folder, then I ls and result as below
/var/www/html/app # ls -ln bootstrap/
total 20
-rwxrwxrwx 1 1000 1000 1396 Oct 4 2019 app.php
-rwxrwxrwx 1 1000 1000 1079 Sep 11 2019 autoload.php
drwxrwxrwx 1 1000 1000 96 Jul 8 2021 cache
-rwxrwxrwx 1 1000 1000 2918 May 26 16:01 container.php
-rwxrwxrwx 1 1000 1000 120 Sep 11 2019 testing-container.php
-rwxrwxrwx 1 1000 1000 713 Feb 3 16:08 testing.php
I did the same in host user (where docker runs), gave 777 and chown to nobody:nobody
ls -l bootstrap
total 40
-rwxrwxrwx 1 nobody nobody 1396 Oct 4 2019 app.php
-rwxrwxrwx 1 nobody nobody 1079 Sep 11 2019 autoload.php
drwxrwxrwx 42 nobody nobody 1344 Jul 8 10:51 cache
-rwxrwxrwx 1 nobody nobody 2918 May 26 18:01 container.php
-rwxrwxrwx 1 nobody nobody 120 Sep 11 2019 testing-container.php
-rwxrwxrwx 1 nobody nobody 713 Feb 3 17:08 testing.php
Still laravel gives me the error permission denied..
I also gave chmod -R 777 bootstrap
from guest
host the one running docker not inside docker itself then docker-compose restart web
, still nothing changed.
The service in docker-compose looks like
web:
user: nobody:nobody
build:
context: .
dockerfile: ./web/Dockerfile
args:
- DOMAIN=${DOMAIN}
restart: on-failure
environment:
DOMAIN: ${DOMAIN}
volumes:
- ${WEB_PATH}:/var/www/html/app
- ./web/default.conf:/etc/nginx/sites-available/${DOMAIN}
expose:
- 8080
container_name: web
Above I even tried to use user nobody as that one is used by nginx but no success
Laravel is running as nobody
user from the error logs:
Server/Request Data
PATH
"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
HOSTNAME
"956b41d4651a"
HOME
"/"
SUPERVISOR_ENABLED
"1"
SUPERVISOR_PROCESS_NAME
"php-fpm"
SUPERVISOR_GROUP_NAME
"php-fpm"
USER
"nobody"
In addition to give 777, i also tried chown -R nobody:nobody bootstrap
inside container itself but still did not work
So is there some way to mount in docker-compose and give ownership to nobody:nobody ? or some other solution