- 使用 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 |