Definite's Extractor

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

Tag Archives: systemd

systemd: remember to keep the daemons alive

My sinopia daemon refused to start. After dig out the journal, I found that ExecStop run straight after ExecStart, what the…

After some research, I found that for daemons, or any other program that put themselves at the background, systemd thought they are stopped, thus stop the service for you. To prevent this, you need following in your systemd service file:

[Service]
...
RemainAfterExit=yes

so your daemons can live happily ever after.

The END

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