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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值