snippetdockerMinor
How to manage services inside the container?
Viewed 0 times
thecontainermanageserviceshowinside
Problem
Systemctl/service commands are not working on a container which is built by using centos:centos7 image.
Can anybody help me here?
Can anybody help me here?
Solution
Using systemd in Docker is not really that straightforward.
However, according to the doc on the docker hub, systemd is now included in both the
However, you will need to include text similar to the example Dockerfile :
I strongly recommend to read the full description tab documentation on the hub. This will help you make it run correctly.
However, according to the doc on the docker hub, systemd is now included in both the
centos:7 and centos:latest base containers.However, you will need to include text similar to the example Dockerfile :
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"]I strongly recommend to read the full description tab documentation on the hub. This will help you make it run correctly.
Code Snippets
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"]Context
StackExchange DevOps Q#8995, answer score: 2
Revisions (0)
No revisions yet.