Created
October 3, 2021 00:26
-
-
Save gwire/912c499a59327beff70b9beb323c1233 to your computer and use it in GitHub Desktop.
Example systemd service for a docker container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Example Container | |
After=docker.service | |
Wants= | |
Requires=docker.service | |
StartLimitIntervalSec=20 | |
StartLimitBurst=3 | |
[Service] | |
TimeoutStartSec=0 | |
Restart=always | |
RestartSec=5 | |
SyslogIdentifier=%N | |
ExecStartPre=-/usr/bin/docker stop %N | |
ExecStartPre=-/usr/bin/docker rm %N | |
ExecStartPre=/usr/bin/docker create --publish 127.0.0.1:9080:80 --name %N example | |
ExecStart=/usr/bin/docker start -a %N | |
ExecStop=/usr/bin/docker stop %N | |
ExecStopPost=-/usr/bin/docker rm %N | |
## some containers will return status=137 SIGKILL on a normal stop | |
SuccessExitStatus=137 | |
[Install] | |
WantedBy=multi-user.target | |
WantedBy=docker.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment