如何在 Raspberry Pi 上运行 Podman Quadlets
发布: (2026年2月17日 GMT+8 19:03)
2 分钟阅读
原文: Dev.to
Source: Dev.to
安装 Podman
sudo apt update && sudo apt install -y podman
典型输出:
Get:1 http://security.debian.org/debian-security trixie-security InRelease [43.4 kB]
Get:2 http://archive.raspberrypi.org/debian trixie InRelease [54.8 kB]
...
Selecting previously unselected package podman.
(Reading database ... 76622 files and directories currently installed.)
Preparing to unpack .../podman_5.4.2+ds1-2+b2_arm64.deb ...
Unpacking podman (5.4.2+ds1-2+b2) ...
Setting up podman (5.4.2+ds1-2+b2) ...
Processing triggers for man-db (2.13.1-1) ...
准备用户环境
为用户启用 linger,这样用户级 systemd 实例会在启动时启动,并在注销后保持运行:
sudo loginctl enable-linger $USER
创建 Quadlet 目录
本地用户的 Quadlet 文件存放在 ~/.config/containers/systemd 下:
mkdir -p ~/.config/containers/systemd
创建示例 Quadlet
创建一个简单的 Nginx 容器 Quadlet:
cat > ~/.config/containers/systemd/hello.container
Welcome to nginx!
...
If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.
For online documentation and support please refer to
[nginx.org](http://nginx.org/).
Commercial support is available at
[nginx.com](http://nginx.com/).
...
在启动时启用服务
在 Quadlet 文件中添加 [Install] 部分,以便像普通 systemd 单元一样进行启用:
cat > ~/.config/containers/systemd/hello.container ../hello.service
配置好 Podman 和 Quadlet 后,容器将作为本地 systemd 单元运行,并在系统启动时自动启动。