Created
October 10, 2017 02:48
-
-
Save RadicalZephyr/94fac2e0ea38476524012becf422968f to your computer and use it in GitHub Desktop.
Generic systemd service file for running service's with docker-compose
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 with docker compose | |
Requires=docker.service | |
After=docker.service | |
[Service] | |
Restart=always | |
WorkingDirectory=/etc/docker/compose/%i | |
# Remove old containers, images and volumes | |
ExecStartPre=-/bin/bash -c 'docker volume ls -qf "name=%i_" | xargs docker volume rm' | |
ExecStartPre=-/bin/bash -c 'docker network ls -qf "name=%i_" | xargs docker network rm' | |
ExecStartPre=-/bin/bash -c 'docker ps -aqf "name=%i_*" | xargs docker rm' | |
# Compose up | |
ExecStart=/usr/local/bin/docker-compose up | |
# After Compose | |
#ExecStartPost= | |
# Compose down, remove containers and volumes | |
ExecStop=/usr/local/bin/docker-compose 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