Last active
July 14, 2019 09:15
-
-
Save jpcaparas/30e733251f95412fa4782c9b9fba9ecd to your computer and use it in GitHub Desktop.
docker-compose systemd 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
# Start the service | |
sudo systemctl start docker-compose@myservice | |
# Enable the service at runtime | |
sudo systemctl enable docker-compose@myservice | |
# Disable the service at runtime | |
sudo systemctl enable docker-compose@myservice | |
# Stop the service | |
sudo systemctl stop docker-compose@myservice | |
# View the logs | |
sudo journalctl -f -b -u docker-compose@myservice |
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] | |
# Bare minimum config to get docker-compose as a systemd service running | |
# Reference: https://gist.github.com/mosquito/b23e1c1e5723a7fd9e6568e5cf91180f | |
Description=%i service with docker-compose | |
Requires=docker.service | |
After=docker.service | |
[Service] | |
WorkingDirectory=/opt/docker-repos/%i | |
TimeoutStartSec=20s | |
RestartSec=5s | |
Restart=always | |
ExecStart=/usr/bin/docker-compose -f docker-compose.yml up | |
ExecStop=/usr/bin/docker-compose -f docker-compose.yml down -v | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment