Docker Centos 7 图片 运行 Apache2 "DocumentRoot ... is not readable"

Docker Centos 7 image running Apache2 "DocumentRoot ... is not readable"

我有一个 docker 容器 运行 一个 Centos 7 镜像。它需要做的只是 运行 一个简单的 Apache2 服务器。当容器启动时,它会立即退出:

AH00526: Syntax error on line 119 of /etc/httpd/conf/httpd.conf:
DocumentRoot '/var/www/html' is not a directory, or is not readable

我做了一些基本检查:

当我使用 bash 入口点进入容器时,我可以使用 /sbin/httpd -D FOREGROUND 以 root 身份启动 apache,一切都按预期进行。

所以我认为这几乎可以肯定是权限问题。谷歌搜索发现很多页面都有我的错误,例如 Apache restart causes DocumentRoot must be a directory, even though it is a directory and there seem to be no privilege issues 这个特定页面详细描述了我得到的内容,几乎每个页面中的解决方案都是配置 SELinux。但是 SELinux 被禁用。即使在 link 中也有来自 OP

的评论

My version of linux isn't Security Enhanced Linux, so without understanding I tried it anyway: no effect.

但他们接受了配置 SELinux 的解决方案。

我想我遗漏了一些东西,几乎肯定与 SELinux 相关,但我想不通。 docker 图像具有以下(明显缺少)SELinux 设置:

看起来 SELinux 确实被禁用了,但错误看起来很像它被启用了。

本例中的问题是由于容器的启动方式所致。

我使用 docker-compose 来启动这个特定的容器,但是卷映射的路径不正确。

我仍然不确定为什么这会导致 apache 无法以它的方式启动,但更正路径可以解决问题。