podman最低系统版本要求RHEL8.2
RHEL8.0的podman版本是1.4或1.6,不建议使用
推荐使用RHEL-Stream,该版本默认安装podman
podman不再要求root权限,podman无守护进程,安装完即用,不需要开启服务.
安装podman
# 安装podman
yum -y install podman
# 查看podman版本
[rhel8 root ~]# podman --version
podman version 3.0.2-dev
podman无守护进程,安装完即用,不需要开启服务.
配置podman镜像加速
podman的默认配置文件/etc/containers/registries.conf
[rhel8 root ~]# ls /etc/containers/registries.conf
/etc/containers/registries.conf
备份主配置文件
[rhel8 root /etc/containers]# mv registries.conf registries.conf.bak
# 新建一个空主配置文件
touch registries.conf
取消辅助配置文件
# 备份registries.conf.d目录,使辅助配置文件不再生效
mv registries.conf.d registries.conf.d.bak
填写配置
填写配置文件,写在文件最下方,或者备份源文件,新建一个空文件,写入配置.
可以自行去https://cr.console.aliyun.com/查看自己的镜像加速地址
# 从哪里拉取一个不合规的镜像,也就是镜像的前缀,从docker.io拉取镜像
unqualified-search-registries = ["docker.io"]
# 从location的地址中拉取docker.io的镜像
[[registry]]
# 匹配哪个地址,触发location
prefix = "docker.io"
# 此处的url不能有http前缀
location = "isdp30x2.mirror.aliyuncs.com"
测试拉取镜像
[rhel8 root ~]# podman pull hello-world
Resolving "hello-world" using unqualified-search registries (/etc/containers/registries.conf)
Trying to pull docker.io/library/hello-world:latest...
Getting image source signatures
Copying blob 2db29710123e done
Copying config feb5d9fea6 done
Writing manifest to image destination
Storing signatures
feb5d9fea6a5e9606aa995e879d862b825965ba48de054caab5ef356dc6b3412
podman配置代理拉取海外镜像
有些情况下,我们生产环境需要拉取海外的镜像源,但是拉取镜像时会超时.这时候需要给podman配置代理.
# 设置临时变量
export https_proxy=127.0.0.1:8118
## 或者直接配置socks5
export https_proxy=socks5://127.0.0.1:10808
# 然后再执行podman pull
podman pull gcr.io/google-containers/ubuntu:14.04
# 用完后取消代理变量
unset https_proxy
# 查看是否取消变量
echo $https_proxy