Docker Centos 7 with httpd24

Viewed 318

I'm still at the beginning with Docker and I have problems when creating a container. I need to create a container from CentOS7, httpd24-httpd, PHP7.2. However, when starting the httpd24-httpd I already have a problem. The call is made through Docker-compose. Here is the 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"]

The docker-compose file:

version: '3.1'

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

Error:

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

Unfortunately, I don't know how to make this work. Can you give me some tips here on how to solve this?

BR

Reiner

1 Answers

systemctl typically not enabled in docker container, so you should directly call command.

For you, next Dockerfile should work:

FROM centos:7

RUN yum -y update
RUN yum -y install httpd

EXPOSE 80

CMD /usr/sbin/apachectl -DFOREGROUND

Execution:

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

Verify the package version:

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

Verify the web page be accessable:

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