Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

Using SystemD Service Script:

https://www.freedesktop.org/software/systemd/man/systemd.service.html


cat << 'EOL' >/lib/systemd/system/container_name.service
[Unit]
Description=Docker_Description
Requires=docker.service network-online.target

[Service]
Restart=on-abnormal
ExecStart=/usr/bin/docker start -a container_name
ExecStop=/usr/bin/docker stop -t 2 container_name

[Install]
WantedBy=multi-user.target
EOL
systemctl enable container_name
systemctl start container_name
systemctl status container_name

https://docs.docker.com/config/containers/start-containers-automatically/

https://askubuntu.com/questions/620930/how-do-i-autostart-docker-container-at-system-reboot


Restart Options:

Takes one of no, on-success, on-failure, on-abnormal, on-watchdog, on-abort, or always. If set to no (the default), the service will not be restarted. If set to on-success, it will be restarted only when the service process exits cleanly. 

Restart settings/Exit causesnoalwayson-successon-failureon-abnormalon-aborton-watchdog
Clean exit code or signal
XX



Unclean exit code
X
X


Unclean signal
X
XXX
Timeout
X
XX

Watchdog
X
XX
X
  • No labels