栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

podman 开机自启

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

podman 开机自启

//拉取一个busybox镜像

[root@10 ~]# podman pull busybox
Resolved "busybox" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull docker.io/library/busybox:latest...
Getting image source signatures
Copying blob 50e8d59317eb done  
Copying config 1a80408de7 done  
Writing manifest to image destination
Storing signatures
1a80408de790c0b1075d0a7e23ff7da78b311f85f36ea10098e4a6184c200964
[root@10 ~]# podman images
REPOSITORY                 TAG         IMAGE ID      CREATED      SIZE
docker.io/library/httpd    latest      c30a46771695  2 weeks ago  148 MB
docker.io/library/busybox  latest      1a80408de790  3 weeks ago  1.46 MB
[root@10 ~]# podman run -itd --name test docker.io/library/busybox:latest
f84b522bdaa2e07ce88fb03b159d6dad97de012837dba42825a56fcf326d49b1

//创建容器自启动service文件
[root@10 ~]# podman generate systemd --files --name test --new
/root/container-test.service



//将生成的文件放到/usr/lib/systemd/system/目录中
[root@10 ~]# ls
anaconda-ks.cfg  container-test.service
[root@10 ~]# mv container-test.service /usr/lib/systemd/system

重启
[root@10 ~]# systemctl daemon-reload
[root@10 ~]# setenforce 0

//修改selinux
[root@10 ~]# vi /etc/selinux/config 
//设置开机自启
[root@10 ~]#  systemctl enable --now container-test.service 
Created symlink /etc/systemd/system/default.target.wants/container-test.service → /usr/lib/systemd/system/container-test.service.
[root@10 ~]# systemctl status container-test.service 
● container-test.service - Podman container-test.service
   Loaded: loaded (/usr/lib/systemd/system/container-test.service; enabled; vendor>
   Active: active (running) since Tue 2022-05-10 19:36:03 CST; 41s ago
     Docs: man:podman-generate-systemd(1)
  Process: 1351 ExecStartPre=/bin/rm -f /run/container-test.service.ctr-id (code=e>
 Main PID: 1713 (conmon)
    Tasks: 2 (limit: 11047)
   Memory: 74.9M
   CGroup: /system.slice/container-test.service
           └─1713 /usr/bin/conmon --api-version 1 -c 2433a45ab40f4561febb5cfbe7e7e>

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/882473.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号