centos - 是否有可能更改 podman 容器的重启策略?
问题描述
是否有可能使用 podman 更改容器重启策略?我们可以在创建容器时设置策略podman run --restart always
,但是创建容器时如何更改呢?
使用 docker 我们有docker update
允许我们这样做的命令。不幸的是,没有podman update
命令。可以做到吗?还是我需要创建一个新容器?
解决方案
使用 podman 时,您应该创建一个管理 podman 容器的 systemd 服务。
- 创建 systemd 文件“/etc/systemd/system/containername.service”
[Unit] Description=your container [Service] Restart=always ExecStart=/usr/bin/podman start -a containername ExecStop=/usr/bin/podman stop -t 2 containername [Install] WantedBy=local.target
- 运行命令:
systemctl 守护进程重载
- 使服务在启动时启动
systemctl enable containername.service
- 重启服务
systemctl restart containername.service
您还可以添加一些其他重启 systemd 参数,例如:
RestartSec (Configures the time to sleep before restarting a service), StartLimitInterval (seconds service is it not permitted to start any more), StartLimitBurst
有关更多详细信息,请查看手册页:“man systemd.service”
推荐阅读
- angular - Promise 中的 Angular 单元测试 catchError
- fullcalendar - 在 FullCalendar 的月/年元素上注入日期选择器
- html - 编写代码以通过 css 和 html 创建带有箭头的表格,如下所示?
- intellij-idea - intellij/android studio idea 显示代码语句的预览气球
- python - 有没有办法让 for 循环将类型从 list 更改为 str?
- swift - 从 KotlinMultiPlatform (KMM) 中的共享类中读取字符数组
- keycloak - Keycloak:Liquibase 正在尝试多次执行变更集,即使它没有更改
- java - Tapestry 确认对话框防止在选择中更改类字段
- javascript - 如何将 MDBootstrap 5 PRO 上传到我的网站?
- java - 双引号不关闭Java