Created
June 28, 2022 19:00
-
-
Save avin/b3832ad22a44d7b201b91eac9f92646b to your computer and use it in GitHub Desktop.
Systemd (systemctl) docker-compse based service
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
# File location: /etc/systemd/system | |
# Enable service to autostart: systemctl enable foo.service | |
[Unit] | |
Description=foo | |
Requires=docker.service | |
After=docker.service | |
[Service] | |
Restart=always | |
WorkingDirectory=/opt/foo/ | |
ExecStartPre=/usr/local/bin/docker-compose -f docker-compose.yml down -v | |
ExecStart=/usr/local/bin/docker-compose -f docker-compose.yml up | |
ExecStop=/usr/local/bin/docker-compose -f docker-compose.yml down | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment