Skip to content

Instantly share code, notes, and snippets.

@ycku
Last active December 31, 2020 09:49
Show Gist options
  • Save ycku/80ede9bff992ab03b8f5dc078bcd6156 to your computer and use it in GitHub Desktop.
Save ycku/80ede9bff992ab03b8f5dc078bcd6156 to your computer and use it in GitHub Desktop.
systemctl PostgreSQL of podman
  • 使用 podman 管理 PostgreSQL Service
  • 透過 systemctl 管理 podman
  • 外部 volume path: /data/postgres.5555/data
  • port 5555 可自訂, 用於突顯內外不同 port
  • selinux disable 比較方便
$ sudo systemctl enable postgres.5555
$ sudo systemctl start postgres.5555
# /etc/sysconfig/postgres.5555
IMAGE=localhost/postgres:13.1
NAME=postgres.5555
# /etc/systemd/system/postgres.5555.service
[Unit]
Description=PostgreSQL Podman container
After=network.target
[Service]
Type=simple
TimeoutStartSec=5m
Restart=always
RestartSec=30s
EnvironmentFile=/etc/sysconfig/postgres.5555
ExecStartPre=-/usr/bin/podman rm ${NAME}
ExecStart=/usr/bin/podman run \
--name ${NAME} \
--publish 5555:5432 \
--volume /data/postgres.5555/data:/var/lib/postgresql/data:Z \
${IMAGE}
ExecReload=-/usr/bin/podman stop ${NAME}
ExecReload=-/usr/bin/podman rm ${NAME}
ExecStop=-/usr/bin/podman stop ${NAME}
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment