
Note: Most of this material, including the Dockerfile itself, appear to be taken from this blog post by Daniel Walsh: Running systemd within a Docker Container. FROM local/c7-systemd RUN yum -y install httpd yum clean all systemctl enable rvice EXPOSE 80 CMD '/usr/sbin/init' Build this image: docker build -rm -t local. It is also noted that on Ubuntu hosts, an additional option may be required for the container to work correctly: $ docker run -it -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v /tmp/$(mktemp -d):/run systemd-app In order to use the systemd enabled base container created above, you will need to create your Dockerfile similar to the one below. The -v option bind mounts the /sys/fs/cgroup directory from the host to the container in a read-only fashion. Running a container from this image also requires a specific option to mount the cgroup volume: $ docker run -it -v /sys/fs/cgroup:/sys/fs/cgroup:ro systemd-app This approach results in a bare-bones, yet functional systemd inside the container. Rm -f /lib/systemd/system//* īy removing these files, systemd is prevented from starting several services during container startup. RUN (cd /lib/systemd/system// for i in * do [ $i = \ The sample Dockerfile provided is as follows: FROM centos:7 You will need to include text similar to the example Dockerfile below: Systemd is now included in both the centos:7 and centos:latest baseĬontainers, but it is not active by default. This is documented at the Docker Hub page for the CentOS image.



The current official Docker image for CentOS does contain systemd, but it is inactive by default.
