Skip to content

systemd

Created on Dec 4, ’22 ・ Updated on Mar 5, ’23

Service example

$ cat /etc/systemd/system/httpd-docker-container.service
[Unit]
Description=httpd-docker-container

[Service]
Restart=always
ExecStart=/usr/bin/docker run --rm -i --name sos-httpd -p 8090:80 -v /home/student/web:/var/www/html:ro sos/httpd
ExecStop=/usr/bin/docker container kill sos-httpd

[Install]
WantedBy=multi-user.target

Misc

# start or stop service
systemctl [start|stop] my-service

# make a service start after boot
systemctl enable my-service

# check service status
systemctl status my-service