Last active
April 15, 2021 22:41
-
-
Save rbuckland/99b29287c802a25f7c454f78aacfeaf0 to your computer and use it in GitHub Desktop.
template systemd service unit - /lib/systemd/system/[email protected]
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=%i service powered by docker compose | |
Requires=docker.service | |
After=docker.service | |
[Service] | |
Restart=always | |
TimeoutStartSec=300 | |
# Create a directory for each docker-composed service at /srv/docker/. | |
# Name the directory as the service. | |
WorkingDirectory=/srv/docker/%i | |
# Remove old containers, images and volumes and update it | |
ExecStartPre=-/usr/local/bin/docker-compose down | |
ExecStartPre=-/usr/local/bin/docker-compose rm -f | |
# Comment the following to not automatically update your images! | |
#ExecStartPre=/usr/bin/docker-compose pull | |
# Run Compose up on service start. | |
ExecStart=/usr/local/bin/docker-compose up | |
# Run Compose down, remove containers and volumes on service stop. | |
ExecStop=/usr/local/bin/docker-compose down | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/lib/systemd/system/[email protected]
- dc meansdocker-compose
WorkingDirectory=/srv/docker/%i
; create a directory theremy-special-thing
, and place yourdocker-compose.yaml
(eg:vi /srv/docker/my-special-thing/docker-compose.yml
)sudo systemctl enable [email protected]
sudo systemctl start [email protected]
, status itsudo systemctl status [email protected]