使用Podman-Quadlet部署halo
2025-09-23 09:55:26

闲来无事,podman5.6更新后quadlet支持管理创建的容器systemctl文件了,比以前确实方便了不少,先将其记录。

本试列podman运行在非root用户环境下。

下载我配置的quadlet文件,该命令自动创建文件夹并下载到其内

wget https://static.muio.net/halo/halo.pod \
 https://static.muio.net/halo/halo.container \
 https://static.muio.net/halo/halo_db.container -P halo
#or
wget https://vip.123pan.cn/1835272502/static/halo/halo.pod \
 https://vip.123pan.cn/1835272502/static/halo/halo_db.container \ 
 https://vip.123pan.cn/1835272502/static/halo/halo.container -P halo

编辑halo.container与halo_db.container的储存挂载与其他自定义参数
虽然可以使用podman quadlet instal url 直接下载并安装但目前没办法将其关联起来所以使用指定文件夹安装
指定文件夹安装可关联内部所有文件并分配.app名称

podman quadlet install halo

#print
#/home/pod/.config/containers/systemd/halo.container
#/home/pod/.config/containers/systemd/halo.pod
#/home/pod/.config/containers/systemd/halo_db.container

列出已安装服务

podman quadlet list 

启动

systemctl --user start halo-pod.service

等待拉取镜像,也可提前拉取
使用root权限允许该普通用户的服务在不登录状态下也可以自启动,这样就可以开机自启了

loginctl enable-linger pod

#podman quadlet list 
#print
#NAME                         UNIT NAME                  PATH ON DISK                                                      STATUS          APPLICATION
#halo.container               halo.service               /home/pod/.config/containers/systemd/halo.container               active/running  .halo.app
#halo.pod                     halo-pod.service           /home/pod/.config/containers/systemd/halo.pod                     active/running  .halo.app
#halo_db.container            halo_db.service            /home/pod/.config/containers/systemd/halo_db.container            active/running  .halo.app

完成。

halo.pod

[Unit]
Description=My Halo Weblog Pod
After=network.target

[Pod]
PodName=halo
PublishPort=8090:8090

halo.container

[Unit]
Description=Halo Weblog  Container
After=halo_db.container

[Container]
AutoUpdate=registry
Pod=halo.pod
StartWithPod=true
ContainerName=halo
Image=registry.fit2cloud.com/halo/halo:2.21
Environment=TZ=Asia/Shanghai LANG=C.UTF-8 JVM_OPTS=-Xmx1024m -Xms1024m
Volume=/home/pod/halo/halo2:/root/.halo2
Exec='--spring.r2dbc.url=r2dbc:pool:postgresql://halo_db/halo' '--spring.r2dbc.username=halo' '--spring.r2dbc.password=openpostgresql' '--spring.sql.init.platform=postgresql' '--halo.external-url=http://localhost:8090/'

HealthCmd=["curl","-f","http://localhost:8090/actuator/health/readiness"]
HealthInterval=30s
HealthRetries=5
HealthStartPeriod=30s
HealthTimeout=5s

[Service]
Restart=always
TimeoutStartSec=900

[Install]
WantedBy=multi-user.target default.target

halo_db.container

[Unit]
Description=Halo DB  Container

[Container]
AutoUpdate=registry
Pod=halo.pod
StartWithPod=true
ContainerName=halo_db
Image=docker.io/postgres:15.4
Environment=TZ=Asia/Shanghai LANG=C.UTF-8 POSTGRES_PASSWORD=openpostgresql POSTGRES_USER=halo POSTGRES_DB=halo PGUSER=halo
Volume=/home/pod/halo/db:/var/lib/postgresql/data

HealthCmd=["pg_isready"]
HealthInterval=10s
HealthRetries=5
HealthTimeout=5s


[Service]
Restart=always
TimeoutStartSec=900

[Install]
WantedBy=multi-user.target default.target
Prev
2025-09-23 09:55:26
Next