Podman 设置开机自启容器

在 Podman 中,原 Docker 使用的–restart参数已经无效。要为一个名叫web的容器设置开机自启动,可采用以下做法。

podman generate systemd --restart-policy always -t 300 -n -f web

其中,–restart-policy参数设置重启策略,-t参数设置超时时间。末尾跟的是容器名。

mv container-web.service /etc/systemd/system/

将建立好的 container-web 服务移到/etc/systemd/system/ 目录下面。

systemctl daemon-reload

重载服务配置文件。

restorecon -RvF container-web.service

container-web 服务打上标记,防止 SELinux 作怪。

systemctl enable container-web.service --now

启用 container-web 服务。

到这里,开机自启就做好了,可通过systemctl进行管理。

赞(0) 打赏
转载请保留出处:耗子博客 » Podman 设置开机自启容器
广告

评论 1

金额随意,一百两百也不介意的啦

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册

Loading...