红帽从 RHEL 9 中删除了 Docker 容器引擎和 docker 命令。从8开始增加dnf,相当于升级的yum
podman 不支持的 docker 命令选项包括 network、node、plugin(podman 不支持插件)、rename(podman 使用 rm 和 create 来重命名容器)、secret、service、stack 和 swarm(podman 不支持 Docker Swarm)。容器和镜像选项用于运行直接在 podman 中使用的子命令。
安装 container-tools meta-package:
# dnf install container-tools
可选:安装 podman-docker 软件包:
# dnf install podman-docker
拉取 rhel 容器镜像:
$ podman pull rhel
//从返回的列表中选择一个下载到本地库
查看本地镜像:
$podman images
将 docker://registry.access.redhat.com/rhel-minimal 镜像复制到本地的目录中:
$ skopeo copy docker://registry.access.redhat.com/rhel-minimal dir:/opt
运行本地镜像,-it带有交互,并命名为rhel7.9:
podman run --name=rhel7.9 -it localhost/rhel9 /bin/bash
启动一个容器并查看运行的容器:
# podman start rhel7.9
rhel7.9
# podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fff55015a9e7 localhost/rhel9:latest /bin/bash 5 hours ago Up 5 seconds rhel7.9
0a62c8f32711 localhost/rhel9:latest /bin/bash 31 minutes ago Exited (127) 2 minutes ago epic_wilbur
运行一个容器内部的命令:
# podman exec rhel7.9 ls -l
total 8
lrwxrwxrwx. 1 root root 7 May 29 03:12 bin -> usr/bin
dr-xr-xr-x. 2 root root 6 Dec 14 2017 boot
drwxr-xr-x. 5 root root 360 Oct 2 18:54 dev
drwxr-xr-x. 31 root root 4096 May 29 03:12 etc
drwxr-xr-x. 2 root root 6 May 29 03:12 home
lrwxrwxrwx. 1 root root 7 May 29 03:12 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 May 29 03:12 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 Dec 14 2017 media
drwxr-xr-x. 2 root root 6 Dec 14 2017 mnt
drwxr-xr-x. 2 root root 6 Dec 14 2017 opt
dr-xr-xr-x. 195 root root 0 Oct 2 18:54 proc
dr-xr-x---. 1 root root 27 Oct 2 14:06 root
drwxr-xr-x. 1 root root 27 Oct 2 14:02 run
lrwxrwxrwx. 1 root root 8 May 29 03:12 sbin -> usr/sbin
drwxr-xr-x. 2 root root 6 Dec 14 2017 srv
dr-xr-xr-x. 13 root root 0 Oct 2 08:52 sys
drwxrwxrwt. 7 root root 117 May 29 03:15 tmp
drwxr-xr-x. 13 root root 155 May 29 03:12 usr
drwxr-xr-x. 18 root root 4096 May 29 03:12 var
# podman exec rhel7.9 cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)
运行一个带交互的容器:
# podman start -a -i rhel7.9
bash-4.2# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var