容器停止因为:" httpd:无法打开配置文件/etc/httpd/conf/httpd.conf:没有这样的文件或目录",为什么?

时间:2017-02-02 19:56:14

标签: docker docker-compose dockerfile

我正在研究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 /

我不确定为什么文件无法找到以及容器停止和退出的原因,是否可以看一下这个并让我知道如果有错误我在哪里?

1 个答案:

答案 0 :(得分:1)

你在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图像中的内容。