Skip to content

Instantly share code, notes, and snippets.

@jbontech
Forked from BenHall/postgres.service
Created September 21, 2021 19:34
Show Gist options
  • Save jbontech/55c6f16370982454f837df0b6fc53801 to your computer and use it in GitHub Desktop.
Save jbontech/55c6f16370982454f837df0b6fc53801 to your computer and use it in GitHub Desktop.
Docker Systemd Unit File
[Unit]
Description=PostgreSQL container
Requires=docker.service
After=docker.service
[Service]
Restart=on-failure
RestartSec=10
ExecStartPre=-/usr/bin/docker stop postgres
ExecStartPre=-/usr/bin/docker rm postgres
ExecStart=/usr/bin/docker run --name postgres \
--volume /srv/db/postgres:/var/lib/pgsql/data \
kiasaki/alpine-postgres
ExecStop=/usr/bin/docker stop postgres
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment