gpt4 book ai didi

docker - 容器停止的原因是: “httpd: Could not open configuration file/etc/httpd/conf/httpd.conf: No such file or directory”,为什么?

转载 作者:行者123 更新时间:2023-12-02 18:31:26 33 4
gpt4 key购买 nike

我正在研究PyroCMS的Docker版本。这是我拥有最新文件的repository。如您所见,我正在运行一个堆栈:CentOS 7(带有Supervisord),MySQL,Apache和PHP。这是docker-compose.yml文件:

version: '2.1'
services:
httpd:
build: docker/httpd
ports:
- "8080:80"
volumes_from:
- php-fpm
php-fpm:
build:
context: docker/php-fpm
args:
INSTALL_XDEBUG: "false"
INSTALL_MONGO: "false"
INSTALL_REDIS: "false"
INSTALL_HTTP_REQUEST: "false"
INSTALL_UPLOAD_PROGRESS: "false"
INSTALL_XATTR: "false"
depends_on:
db:
condition: service_healthy
db:
image: mysql
healthcheck:
test: "exit 0"
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}

这是 Dockerfile图片的 httpd:
FROM reynierpm/centos7-supervisor
RUN yum install -y httpd nano && \
yum clean all && rm -rf /tmp/yum*
RUN rm -f /etc/httpd/conf/httpd.conf /etc/httpd/conf.d/* /etc/httpd/conf.modules.d/*
COPY container-files /
EXPOSE 80

我遇到了问题,因为 httpd容器以状态1退出并查看日志,我得到以下信息:
httpd_1  | httpd: Could not open configuration file /etc/httpd/conf/httpd.conf: No such file or directory

乍一看,您会说:

您正在删除文件!!!在此行 RUN rm -f /etc/httpd/conf/httpd.conf /etc/httpd/conf.d/* /etc/httpd/conf.modules.d/*
而且您是对的,但是如果仔细看,您会发现我正在将其复制回该行(因为我正在运行最小的Apache配置):
COPY container-files /

我不确定为什么找不到该文件以及为什么容器正在停止和退出,有什么可以看一下并让我知道哪里出错了吗?

最佳答案

您在php-fpm Dockerfile中具有以下代码:

VOLUME ["/data/www", "/etc/httpd"]

而这在docker-compose.yml中:

httpd:
build: docker/httpd
ports:
- "8080:80"
volumes_from:
- php-fpm

因此,您的httpd镜像最终会在 /etc/httpd处进行卷装载。该卷的内容将覆盖在构建时烘焙到 httpd图像中的所有内容。

关于docker - 容器停止的原因是: “httpd: Could not open configuration file/etc/httpd/conf/httpd.conf: No such file or directory”,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42011196/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com