一,配置加速器
[root@localhost ~]# vim /etc/containers/registries.conf
unqualified-search-registries = ["docker.io"]
[[registry]]
prefix = "docker.io"
location = "2rdng78w.mirror.aliyuncs.com"
二、podman容器的开机自启
root用户
[root@localhost ~]# 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 5cc84ad355aa done
Copying config beae173cca done
Writing manifest to image destination
Storing signatures
beae173ccac6ad749f76713cf4440fe3d21d1043fe616dfbe30775815d1d0f6a
[root@localhost ~]# podman run --name test -dit docker.io/library/busybox
59eab2d63ddc3f56a25fcd460081a0ab50f9f60c72f928e783fe2191db0b664d
[root@localhost ~]# podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
59eab2d63ddc docker.io/library/busybox:latest sh 10 seconds ago Up 9 seconds ago test
#创建容器自启动service文件
[root@localhost ~]# podman generate systemd --files --name test
/root/container-test.service
#如果希望每次启动容器都会删除旧的容器,启动一个全新的容器,则使用--new选项(推荐用法)
[root@localhost ~]# podman generate systemd --files --name test --new
/root/container-test.service
[root@localhost ~]# ls
公共 视频 文档 音乐 anaconda-ks.cfg initial-setup-ks.cfg
模板 图片 下载 桌面 container-test.service Nginx
[root@localhost ~]# mv container-test.service /usr/lib/systemd/system
#重载
[root@localhost ~]# systemctl daemon-reload
#关闭selinux
[root@localhost ~]# setenforce 0
[root@localhost ~]# vim /etc/selinux/config
SELINUX=disabled
#设置容器自启动
[root@localhost ~]# 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@localhost ~]#