【问题标题】:Docker Centos 7 with httpd24带有 httpd24 的 Docker Centos 7
【发布时间】:2021-06-10 19:43:52
【问题描述】:

我还处于 Docker 的起步阶段,在创建容器时遇到了问题。我需要从 CentOS7、httpd24-httpd、PHP7.2 创建一个容器。但是,在启动 httpd24-httpd 时,我已经遇到了问题。调用是通过 Docker-compose 进行的。 这是dockerfile:

FROM centos:7

# Install httpd24
RUN yum -y update
RUN yum -y install centos-release-scl-rh
RUN yum -y install httpd24-httpd

EXPOSE 80

# Start httpd24
CMD ["systemctl","start","httpd24-httpd"]

docker-compose 文件:

version: '3.1'

services:
    centos:
        build: ./centos7
        ports:
            - "80:80"
        volumes: 
            - .:/code
            - ./centos7/www:/var/www/html

错误:

centos_1 | Failed to get D-Bus connection: Operation not permitted

很遗憾,我不知道如何进行这项工作。你能在这里给我一些关于如何解决这个问题的提示吗?

BR

莱纳

【问题讨论】:

    标签: docker apache docker-compose centos7


    【解决方案1】:

    systemctl 通常在 docker 容器中没有启用,所以你应该直接调用命令。

    对你来说,下一个 Dockerfile 应该可以工作:

    FROM centos:7
    
    RUN yum -y update
    RUN yum -y install httpd
    
    EXPOSE 80
    
    CMD /usr/sbin/apachectl -DFOREGROUND
    

    执行:

    $ docker build -t abc:1 .
    $ docker run -idt -p 80:80 --name trial abc:1
    

    验证包版本:

    $ docker exec -it trial rpm -qa httpd
    httpd-2.4.6-97.el7.centos.x86_64
    

    验证网页是否可访问:

    $ docker exec -it trial curl http://localhost
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-05
      • 1970-01-01
      • 2018-06-09
      • 1970-01-01
      • 2019-11-13
      • 1970-01-01
      • 2014-12-15
      • 2017-10-30
      相关资源
      最近更新 更多