Last active
March 3, 2020 13:51
-
-
Save johananl/5af722885a98d4941abc383f66b26389 to your computer and use it in GitHub Desktop.
Run a Docker container as a systemd unit
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=PostgreSQL | |
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 postgres | |
ExecStart=/usr/bin/docker run --rm --name %n \ | |
--env-file /etc/postgres/postgres.env \ | |
-v pgdata:/var/lib/postgresql/data \ | |
-p 172.17.0.1:5432:5432 \ | |
postgres | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment