TrafeX / docker-php-nginx

Docker image with PHP-FPM 8.3 & Nginx 1.26 on Alpine Linux
https://hub.docker.com/r/trafex/php-nginx
MIT License
1.37k stars 736 forks source link

nginx not start with permission denied #102

Closed PikuZheng closed 2 years ago

PikuZheng commented 2 years ago

Hi, Thanks your working first. I'm using docker run -p 80:8080 -v /userdata/php/html:/var/www/html trafex/php-nginx:latest everything works fine unitil I recreated it with

docker run -p 80:8080  -v "/userdata/php/config:/etc/nginx/conf.d" -v /userdata/php/html:/var/www/html trafex/php-nginx:latest

it's not stating with logs:

2022-09-01 07:26:05,292 INFO supervisord started with pid 1
2022-09-01 07:26:06,295 INFO spawned: 'nginx' with pid 7
2022-09-01 07:26:06,298 INFO spawned: 'php-fpm' with pid 8
nginx: [emerg] open() "/etc/nginx/conf.d/nginx.conf" failed (13: Permission denied) in /etc/nginx/nginx.conf:95
2022-09-01 07:26:06,313 INFO exited: nginx (exit status 1; not expected)
2022-09-01 07:26:06,344 INFO gave up: nginx entered FATAL state, too many start retries too quickly
[01-Sep-2022 07:26:06] NOTICE: fpm is running, pid 8
[01-Sep-2022 07:26:06] NOTICE: ready to handle connections
2022-09-01 07:26:07,358 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

but

root@photon-machine [ ~ ]# ls -l /userdata/php/config
total 12
-rw-r--r-- 1 nobody nobody 3678 Sep  1 14:39 fullchain.pem
-rw-r--r-- 1 nobody nobody 1833 Sep  1 15:10 nginx.conf
-rw-r--r-- 1 nobody nobody 1706 Sep  1 14:39 privkey.pem

what should I do now?

TrafeX commented 2 years ago

Hi @PikuZheng,

Can you post the output when you run this command:

docker run -p 80:8080 -ti -v "/userdata/php/config:/etc/nginx/conf.d" -v /userdata/php/html:/var/www/html trafex/php-nginx:latest ls -la /etc/nginx/conf.d
PikuZheng commented 2 years ago
localhost:~# docker run -p 81:8080 -ti -v "/userdata/php/config:/etc/nginx/conf.d" -v /userdata/php/html:/var/www/html trafex/php-nginx:latest ls -la /etc/nginx/conf.d
total 20
drwxr-xr-x    2 root     root          4096 Sep  6 07:05 .
drwxr-xr-x    1 root     root          4096 Sep  6 23:42 ..
-rw-r--r--    1 root     root          3678 Sep  1 06:39 fullchain.pem
-rw-r--r--    1 root     root          2277 Sep  3 07:10 nginx.conf
-rw-r--r--    1 root     root          1706 Sep  1 06:39 privkey.pem
PikuZheng commented 2 years ago
drwxr-xr-x    2 nginx     nginx          4096 Sep  1 06:54 conf.d

damn! after chown it to root, everything works.

TrafeX commented 2 years ago

Yeah that's a bit annoying with Docker volumes. Glad it's solved!