Definite's Extractor

My findings on Life, Linux, Open Source, and so on.

Monthly Archives: November 2014

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.

yum -y swap -- remove fakesystemd -- install systemd systemd-libs

So here is my final docker script systemd_rhel7 (which also run httpd)

FROM rhel-server-docker-7.0-23.x86_64
MAINTAINER “Ding-Yi Chen” <dchen@redhat.com>
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
EXPOSE 80
VOLUME [ "/sys/fs/cgroup" ]
CMD ["/usr/sbin/init"]

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

curl http://localhost