podman 容器作为服务管理


创建服务配置

# 创建配置,打印到 stdout
podman generate systemd --new --name "$CONTAINER_NAME"

# 复制到 User-scope 的服务配置
mkdir -p ~/.config/systemd/user/
mv -v "container-$CONTAINER_NAME.service" ~/.config/systemd/user/

# Reload 配置并启用
systemctl --user daemon-reload
systemctl --user enable "container-$CONTAINER_NAME.service"

# 查看状态
systemctl --user status "container-$CONTAINER_NAME.service"

参考

  • https://www.tutorialworks.com/podman-systemd/
  • https://github.com/containers/podman/issues/10539
  • https://askubuntu.com/questions/676007/how-do-i-make-my-systemd-service-run-via-specific-user-and-start-on-boot
  • https://stackoverflow.com/questions/65162259/is-there-a-possibility-to-change-restart-policy-of-podman-container

文章作者: sfc9982
版权声明: 本博客所有文章除特別声明外,均采用 CC BY-NC-ND 4.0 许可协议。转载请注明来源 sfc9982 !
  目录