//拉取一个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>
podman 开机自启
最新推荐文章于 2022-11-25 15:12:47 发布