Repository navigation
unix_systemd
Andrea Paolini edited this page Jan 2, 2021
·
1 revision
For an introduction see http://www.enricozini.org/blog/2017/debian/systemd-01-intro/
systemctl stop myservice
systemctl start myservice
systemctl restart myservice
systemctl reload myservice
systemctl status myservice
systemctl enable myservice
systemctl disable myservice
systemctl is-enabled myservice
systemctl list-unit-files --type=service
or simply:
systemctl
Reload systemd, scanning for new or changed units:
systemctl daemon-reload
[Service]
Restart=on-failure
RestartSec=30
cfr systemctl edit ...
AKA builtin "variables" for unit files(i.e. hostname): see systemd.unit(5)
# Logs from last boot
journalctl -b
# Follow logs
journalctl -f
# From kernel
journalctl -k
# From a specific binary
journalctl /usr/bin/pippo
# In reverse order (newest first)
journalctl -r
This requires a fairly recent version of CentOS7 or CentOS8
- If using SElinux enable
setsebool -P container_manage_cgroup 1in the host - In the Dockerfile:
- Use the latest centos:7 or centos:8 base image
- Set the environment variable container=docker
- Set STOPSIGNAL to SIGRTMIN+3 to allow for a clean stop
- use /sbin/init as a CMD
Example:
FROM centos:7
ENV container docker
STOPSIGNAL SIGRTMIN+3
RUN yum -y install httpd
systemctl enable httpd
EXPOSE 80
CMD [ "/sbin/init" ]Work in progress...