Running systemd within a docker container with RHEL7
I have learned a lot from Running systemd within a docker container, but it does not actually work in RHEL7, at least not the Red Hat official docker image , because fakesystemd is blocking the way.
Fortunately, I found the Review request of fakesystemd, which offer the way to swap the fakesystemd.
So here is my final docker script systemd_rhel7 (which also run httpd)
MAINTAINER “Ding-Yi Chen” <firstname.lastname@example.org>
ENV container docker
RUN yum -y update
RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs
RUN yum -y install httpd ; yum clean all
RUN systemctl enable httpd.service
VOLUME [ "/sys/fs/cgroup" ]
To build the image:
docker build -t systemd_rhel7 .
To run the container, note that it may kick you out of the system, but don’t worry, you just login back.
docker run –privileged -ti -v /sys/fs/cgroup:/sys/fs/cgroup:ro -p 80:80 systemd_rhel7
To test it