I'm using docker compose to boot up a development workspace, consisting of php, nginx and mysql. Everything boots, static html get's served, but when trying to start a laravel app, i get the following error:
The stream or file "/home/html/storage/logs/laravel-2019-06-10.log" could not be opened: failed to open stream: Permission denied
I searched around and it looked like a permissions issue? Do note, that the docker with just the database and the build in php server does seem to work.
My docker-compose.yml
version: "3"
services:
db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: "root"
ports:
- 3306:3306
php-fpm:
image: php:7.3-fpm-alpine
links:
- db
volumes:
- "./:/home/html/"
nginx:
image: nginx:1-alpine
ports:
- "8080:80"
links:
- php-fpm
volumes:
- "./site.conf:/etc/nginx/conf.d/default.conf"
- "./:/home/html/"
My nginx config:
server {
index index.php index.html;
listen 80 default_server;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /home/html/public;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
遇到了同样的问题,在CSDN看到了,希望阿里云团队能够给出正确、标准的答案~请查看
把宿主机的一个目录挂载到容器中的一个目录,当访问容器中的这个目录时,出现如下问题: 2018/06/29 02:13:42 [emerg] 1#1: mkdir() "/data/nginx/tmp-test" failed (13: Permission denied) nginx: [emerg] mkdir() "/data/nginx/tmp-test" failed (13: Permission denied)
2018/06/29 02:17:48 [emerg] 1#1: chown("/data/nginx/tmp-test", 101) failed (13: Permission denied) nginx: [emerg] chown("/data/nginx/tmp-test", 101) failed (13: Permission denied)
无法访问目录,权限拒绝。该问题通常在centos7下出现。或者一个容器启动成功后,里面的服务无法成功访问,这是因为centos7中的安全模块selinux把权限禁掉了,一般的解决方案有以下两种:
(1)临时关闭selinux 直接在centos服务器上执行以下命令即可。执行完成以后建议重新docker run。 setenforce 0
(2)给容器加权限 在docker run时给该容器加权限,加上以下参数即可: --privileged=true
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。