Podman
Podman 是 Docker 的无守护进程(Daemonless)替代方案,支持 无根容器(Rootless Container),无需 root 权限即可运行。
为什么选择 Podman?
| 特性 | Docker | Podman |
|---|---|---|
| 守护进程 | 需要 dockerd | 不需要 |
| Root 权限 | 默认需要 | 无根运行 |
| systemd 集成 | 需要额外配置 | 原生 Quadlet 支持 |
| OCI 兼容 | ✅ | ✅ |
| Compose | Docker Compose | podman-compose 或 podman compose |
快速安装
使用官方引导脚本
bash
git clone https://github.com/openclaw/openclaw.git
cd openclaw
./setup-podman.shsetup-podman.sh 位于仓库根目录,运行后会:
- 安装 Podman(如果未安装)
- 拉取 OpenClaw Gateway 镜像
- 创建 systemd Quadlet 服务
- 启动 Gateway
手动安装 Podman
bash
sudo apt install -y podmanbash
sudo dnf install -y podmanbash
brew install podman
podman machine init
podman machine start手动部署
bash
# 拉取镜像
podman pull ghcr.io/openclaw/gateway:latest
# 创建并运行容器
podman run -d \
--name openclaw-gateway \
--restart unless-stopped \
-p 18789:18789 \
-v openclaw-data:/home/openclaw/.openclaw:Z \
-e NODE_ENV=production \
ghcr.io/openclaw/gateway:latest
# 查看日志
podman logs -f openclaw-gatewaySELinux 标签
注意挂载卷时的 :Z 后缀——这会让 Podman 自动设置 SELinux 安全标签,避免权限问题。在 Fedora / RHEL 系统上必须添加。
systemd Quadlet(推荐)
Quadlet 是 Podman 内置的 systemd 容器管理方案,让容器像系统服务一样管理。
创建文件 ~/.config/containers/systemd/openclaw-gateway.container:
ini
[Unit]
Description=OpenClaw Gateway
After=network-online.target
[Container]
Image=ghcr.io/openclaw/gateway:latest
ContainerName=openclaw-gateway
PublishPort=18789:18789
Volume=openclaw-data:/home/openclaw/.openclaw:Z
Environment=NODE_ENV=production
AutoUpdate=registry
[Service]
Restart=on-failure
RestartSec=10
[Install]
WantedBy=default.target启用服务:
bash
# 重新加载 systemd 配置
systemctl --user daemon-reload
# 启动
systemctl --user start openclaw-gateway
# 开机自启
systemctl --user enable openclaw-gateway
loginctl enable-linger $USER
# 查看状态
systemctl --user status openclaw-gateway排障
端口绑定失败(无根模式下 < 1024 端口)
无根容器默认不能绑定 1024 以下端口:
bash
# 方法一:使用 18789 端口(推荐)
# 方法二:允许无特权端口绑定
sudo sysctl net.ipv4.ip_unprivileged_port_start=80镜像拉取超时
bash
# 检查 registry 配置
podman info | grep -A5 registries
# 手动指定 registry
podman pull docker.io/library/ubuntu:22.04容器内 DNS 解析失败
bash
# 检查 /etc/resolv.conf
podman exec openclaw-gateway cat /etc/resolv.conf
# 手动指定 DNS
podman run --dns 8.8.8.8 ...🇨🇳 中国用户须知
Podman 同样支持镜像加速。编辑 ~/.config/containers/registries.conf:
toml
[[registry]]
location = "ghcr.io"
[[registry.mirror]]
location = "ghcr.nju.edu.cn"或使用阿里云容器镜像加速器。
