【问题标题】:Docker php:5.6-apache 403 (because search permissions are missing on a component of the path)Docker php:5.6-apache 403 (因为路径的组件上缺少搜索权限)
【发布时间】:2017-07-24 11:51:27
【问题描述】:

文件树:

├── docker-compose.yml 
├── Dockerfile 
└── www 
    └── index.html

Docker 文件:

FROM php:5.6-apache
ADD ./www /var/www/html/
WORKDIR /var/www/html/

docker-compose.yml

version: '2'
services:
  php5_6:
    build: .
    ports :
     - "80:80"
    volumes:
     - ./www:/var/www/html/

尝试启动docker

$ docker-compose up
[core:error] [pid 17] (13)Permission denied: [client 172.19.0.1:53514] AH00035: access to /index.html denied (filesystem path '/var/www/html/index.html') because search permissions are missing on a component of the path

在浏览器http://localhost403页面中

怎么了?

【问题讨论】:

    标签: php docker docker-compose


    【解决方案1】:

    错误消息表明 apache 没有对 html 目录的适当访问权限。特别是它可能需要执行权限以及读取权限。

    尝试将RUN chmod -R 755 /var/www/html/ 添加到您的 Dockerfile。

    【讨论】:

      【解决方案2】:

      问题是启用了 SELinux。在 /etc/selinux/conf 中禁用即可解决。

      【讨论】:

      • 这可能有效,但 PraAnj 的回答要好得多。
      【解决方案3】:

      我知道我的回答迟了,但其他人会从这个回答中得到一些帮助。

      在末尾使用:z:Z 选项以安装具有足够权限的卷。确切地说,这将添加一个 selinux 规则 chcon -Rt svirt_sandbox_file_t /path/to/volume

      version: '2'
      services:
      php7_2:
        build: .
        ports :
         - "80:80"
        volumes:
         - "./www:/var/www/html/:Z"
      

      阅读更多详情,

      1. http://www.projectatomic.io/blog/2015/06/using-volumes-with-docker-can-cause-problems-with-selinux/
      2. Permission denied on accessing host directory in docker

      【讨论】:

      • 这也适用于podman run-v 选项来挂载卷。只需附加:Z
      猜你喜欢
      • 2014-10-01
      • 2017-09-05
      • 2016-12-23
      • 1970-01-01
      • 2016-02-02
      • 1970-01-01
      • 2022-01-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多