$ sudo cp [email protected] /etc/systemd/system
$ sudo systemctl daemon-reload
$ sudo systemctl enable docker-compose@mongodb
$ sudo systemctl start docker-compose@mongodb
Created
March 26, 2020 22:56
-
-
Save islander/0d69885fe7fe806eff85a286b738ef97 to your computer and use it in GitHub Desktop.
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 service with docker-compose | |
Requires=docker.service | |
After=docker.service | |
[Service] | |
Restart=always | |
WorkingDirectory=/opt/docker/%i | |
# Remove old containers, network and volumes | |
ExecStartPre=/usr/local/bin/docker-compose down -v | |
ExecStartPre=-/bin/bash -c 'docker network rm %i_' | |
ExecStartPre=-/bin/bash -c 'docker ps -aqf "name=%i_" | xargs docker rm' | |
# Compose up | |
ExecStart=/usr/local/bin/docker-compose up | |
# Compose down, remove containers | |
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