Podman 是一個(gè)開(kāi)源的容器運(yùn)行時(shí)項(xiàng)目,可在大多數(shù) Linux 平臺(tái)上使用煞躬,在 RedHat/CentOS8 版本已默認(rèn)安裝。Podman 可以管理和運(yùn)行任何符合 OCI(Open Container Initiative)規(guī)范的容器和容器鏡像。Podman 提供與 Docker 非常相似的功能奕剃,并且使用與 Docker 兼容的命令行前端來(lái)管理鏡像。
Podman 和 Docker 的使用方法幾乎完全一致捐腿。其中 podman 指令對(duì)應(yīng) docker 指令纵朋,podman-compose 指令對(duì)應(yīng) docker-compose 指令。
Podman 支持使用非 root 用戶創(chuàng)建和管理容器茄袖,但是部分功能(如:目錄掛載和宿主機(jī)磁盤(pán)掛載)會(huì)出現(xiàn)用戶權(quán)限引起的問(wèn)題操软,因此特別推薦使用 root 權(quán)限創(chuàng)建和管理容器。
關(guān)于 Docker 和 Docker-Compose 的使用方法請(qǐng)閱讀文章《RedHat/CentOS8【Docker】鏡像制作編排和容器部署》宪祥,文章地址【http://www.reibang.com/p/a4198b127729】聂薪。
1、安裝 Podman 和 Podman-Compose品山。
1)安裝 Podman:
[root@host ~]# dnf install podman podman-plugins cockpit cockpit-podman
[root@host ~]# systemctl enable --now podman
[root@host ~]# systemctl enable --now cockpit.socket
安裝cockpit和cockpit-podman后胆建,可以通過(guò)【https://ip:9090】來(lái)管理容器。
2)安裝 Podman-Compose:
[root@host ~]# dnf install python3
[root@host ~]# pip3 install podman-compose
程序安裝位置:
鏡像管理程序:/usr/bin/podman
編譯文件執(zhí)行程序:/usr/local/bin/podman-compose
配置文件目錄:/etc/containers肘交,/usr/share/containers
更新
[root@host ~]# dnf upgrade podman
[root@host ~]# pip3 install -U podman-compose
2笆载、設(shè)置國(guó)內(nèi)鏡像倉(cāng)庫(kù)加速器。
1)備份原配置文件:
[root@host ~]# cp /etc/containers/registries.conf /etc/containers/registries.conf.bak
2)使用文本編輯器打開(kāi)配置文件:
[root@host ~]# vi /etc/containers/registries.conf
3)刪除原有內(nèi)容涯呻,重新編寫(xiě)文件內(nèi)容后保存:
unqualified-search-registries = ["docker.io"]
[[registry]]
prefix = "docker.io"
location = "docker.io"
[[registry.mirror]]
location = "mirror.baidubce.com"
[[registry.mirror]]
location = "gms53j1g.mirror.aliyuncs.com"
4凉驻、設(shè)置鏡像倉(cāng)庫(kù)和運(yùn)行時(shí)目錄。
1)創(chuàng)建鏡像倉(cāng)庫(kù)目錄:
[root@host ~]# mkdir -p /data/containers/{run,graph}
2)備份原配置文件:
[root@host ~]# cp /etc/containers/storage.conf /etc/containers/storage.conf.bak
3)使用文本編輯器打開(kāi)配置文件:
[root@host ~]# vi /etc/containers/storage.conf
4)修改文件以下內(nèi)容后保存:
# root 用戶運(yùn)行時(shí)目錄
runroot = "/data/containers/run"
# root 用戶鏡像倉(cāng)庫(kù)目錄
graphroot = "/data/containers/graph"
5复罐、修改 SELinux 配置文件涝登,永久關(guān)閉 SELinux。
使用文本編輯器打開(kāi)"/etc/selinux/config"文件:
[root@host ~]# vi /etc/selinux/config
將 "SELINUX" 參數(shù)設(shè)置為:"permissive" 或者 "disabled"效诅,并保存:
# enforcing - 表示啟用 SELinux 安全策略胀滚。
# permissive - 表示啟用 SELinux 安全策略,但不強(qiáng)制驗(yàn)證乱投。如果執(zhí)行第一步可以正常運(yùn)行咽笼,則建議設(shè)置此值。
# disabled - 關(guān)閉 SELinux 安全策略戚炫,相當(dāng)于沒(méi)有安裝 SELinux剑刑。
SELINUX=disabled
重啟服務(wù)器:
[root@host ~]# reboot