Last active
July 19, 2018 22:12
-
-
Save johananl/61ba65b0af7211dfd58ff1d20ec69ee6 to your computer and use it in GitHub Desktop.
Running a container as a systemd service
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
# Put this file under /etc/systemd/system/redis.service | |
[Unit] | |
Description=Redis Container | |
After=docker.service | |
Requires=docker.service | |
[Service] | |
TimeoutStartSec=0 | |
Restart=always | |
ExecStartPre=-/usr/bin/docker stop %n | |
ExecStartPre=-/usr/bin/docker rm %n | |
ExecStartPre=/usr/bin/docker pull redis | |
ExecStart=/usr/bin/docker run --rm --name %n redis | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment