podman简介
Podman 是 RedHat 开发的一个无守护进程的开源 Linux 原生容器引擎,用于构建、运行和管理 Linux OCI 容器与容器镜像。Podman 于 2018 年初首次发布,原来是 CRI-O 项目的一部分,后来被分离为一个单独的项目 libpod。
为了安全的运行容器,容器社区在红帽的推动下发布了更安全的容器工具集合:Podman、runc、systemd、Buildah、skopeo。Podman的目标就是无缝替换Docker,并且更安全。
Docker 和 Podman 之间的一个显著区别是,Docker 运行一个持久的、自给自足的运行时来管理其对象或称为 dockerd 的守护进程;而 Podman 并不依赖守护进程来工作,也正因如此,Podman 被称为无守护进程的容器技术。
官方网站:https://podman.io/
项目地址:https://github.com/containers/podman
podman安装使用
默认源安装,centos
$ dnf install -y podman
ubuntu
$ apt install -y podman
安装最新版本,podman 包位于 PPA 存储库中,需要在安装之前添加该存储库,以 Ubuntu 22.04 为例
添加存储库
echo 'deb http://download.opensuse.org/repositories/home:/alvistack/xUbuntu_22.04/ /' | sudo tee /etc/apt/sources.list.d/home:alvistack.list
curl -fsSL https://download.opensuse.org/repositories/home:alvistack/xUbuntu_22.04/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_alvistack.gpg > /dev/null
安装podman
sudo apt update
sudo apt install -y podman
查看安装版本
root@ubuntu:~# podman version
Client: Podman Engine
Version: 4.1.0
API Version: 4.1.0
Go Version: go1.18.2
Built: Thu Jan 1 08:00:00 1970
OS/Arch: linux/amd64
配置镜像加速
这里使用阿里云镜像加速器
cp /etc/containers/registries.conf{,.bak}
cat > /etc/containers/registries.conf << EOF
unqualified-search-registries = ['registry.access.redhat.com', 'registry.fedoraproject.org', 'registry.centos.org', 'docker.io']
[[registry]]
prefix = "docker.io"
insecure = true
location = "docker.io"
[[registry.mirror]]
location = "uyah70su.mirror.aliyuncs.com"
EOF
拉取镜像
$ podman pull centos
Trying to pull docker.io/library/centos...Getting image source signatures
Copying blob 8ba884070f61 done
Copying config 9f38484d22 done
Writing manifest to image destination
Storing signatures
9f38484d220fa527b1fb19747638497179500a1bed8bf0498eb788229229e6e1
查看镜像
$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/centos latest 9f38484d220f 4 months ago 209 MB
运行容器
$ podman run -itd --name test centos sleep 3600
1fc033bb22096008049709d70869d54e3fa9e4d72c6d098f4b5601fd6747a9b9
查看容器
$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1fc033bb2209 docker.io/library/centos:latest sleep 3600 7 seconds ago Up 6 seconds ago test
配置代理,podman 读取HTTP_PROXY环境变量以获取信息。
cat >/etc/profile.d/podman_http_proxy.sh<<EOF
export HTTP_PROXY=http://192.168.0.1:3128
export HTTPS_PROXY=http://192.168.0.1:3128
EOF
source /etc/profile