Created
January 30, 2021 01:14
-
-
Save nothub/294a2ae9d78f210b1d8842293c0d9af3 to your computer and use it in GitHub Desktop.
docker-compose systemd unit template
This file contains 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=%i (docker-compose) | |
Requires=docker.service | |
After=docker.service | |
[Service] | |
Restart=always | |
TimeoutStartSec=300 | |
# restart twice a day to pull image updates | |
RuntimeMaxSec=43200 | |
# services reside in /opt/docker/<SERVICENAME> | |
# example: /opt/docker/service-a/docker-compose.yml | |
WorkingDirectory=/opt/docker/%i | |
# remove old containers and update image | |
ExecStartPre=/usr/local/bin/docker-compose rm --force --stop | |
ExecStartPre=/usr/local/bin/docker-compose pull | |
# compose up (compatibility for pre docker machine stuff) | |
ExecStart=/usr/local/bin/docker-compose --compatibility up | |
# compose down, remove containers | |
ExecStop=/usr/local/bin/docker-compose down --timeout 60 | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment