I’ve followed the documentation :Systemd integration on Docker hub to create a docker image with systemd
Base Image Docker file
FROM centos:7
ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup" ]
CMD ["/usr/sbin/init"]
Modified the build command mentioned in documentation from
$ docker build --rm -t local/c7-systemd .
to
$ docker build --platform linux/x86_64 --rm -t local/c7-systemd .
Then, built a child docker image
Child image Docker file -
FROM local/c7-systemd
RUN yum -y install httpd; yum clean all; systemctl enable httpd.service
EXPOSE 80
CMD ["/usr/sbin/init"]
Modified build file from
$ docker build --rm -t local/c7-systemd-httpd .
to
docker build --platform linux/x86_64 --rm -t local/c7-systemd-httpd .
ran the docker with
docker run --platform linux/x86_64 -ti -v /sys/fs/cgroup:/sys/fs/cgroup:ro -p 80:80 local/c7-systemd-httpd
Unfortunately got the error message
Failed to mount tmpfs at /run: Operation not permitted
Failed to mount cgroup at /sys/fs/cgroup/systemd: Operation not permitted
[!!!!!!] Failed to mount API filesystems, freezing.
My requirement is to build a container with
-
Apache
-
PHP 8.1
with linux/x86_64 architecture in centos 7
Any help is appreciated.
Thanks in advance.