Podman 学习和实践笔记

2026-09-17
2分钟阅读时长

Podman 是一个开源的容器引擎,它采用无守护进程(daemonless)架构,直接以普通进程运行容器,不需要像 Docker 那样常驻一个后台 daemon;同时支持无 root 权限(rootless)运行,系统的普通用户即可创建和管理容器,安全性更好。

Podman 的命令行与 Docker 高度兼容,大部分直接就能用,我们主要用它来替代 Docker,用于本地开发、CI/CD和容器化的测试环境部署等。

Rocky Linux 下的安装

# dnf install podman

常用命令

$ podman version

$ podman system info

$ podman info

搜索镜像、拉取镜像、列出本地镜像

$ podman search quay.io/centos							// 加上源进行搜索,列出镜像源的全路径

$ podman pull quay.io/centos/centos:centos7	            // 拉取 centos7 的镜像

$ podman images											// 列出已存在的镜像
$ podman images ls

$ podman rmi <imageID>									// 从本地存储中删除镜像

$ podman tag <imageID> <镜像名称>						 // 给本地镜像设置一个别名

运行、查看、停止、删除容器

$ podman run --name centos7.9.2009 quay.io/centos/centos:centos7
$ podman run --name centos7.9.2009 -dt quay.io/centos/centos:centos7
$ podman run --name centos7.9.2009 -it quay.io/centos/centos:centos7
$ podman ps												// 列出正在运行的容器

$ podman ps -a											// 列出所有容器(已创建、已退出、正在运行的)

$ podman inspect -l | grep "IPAddress"			       // 检查正在运行的容器

$ podman stop <container id>						  // 停止指定 container id 的容器的运行
$ podman stop -l 									  // -l 是指最新的、最近的容器
$ podman logs -l										// 查看容器的日志
$ podman top -l											// 查看容器的 PID
$ podman rm -l											// 删除容器

podman 命令参考: https://docs.podman.org.cn/en/latest/Commands.html

容器镜像注册表

quay.io - https://quay.io

国内镜像源

  • 阿里云

使用 Dockerfile / Containerfile 构建自有镜像

$ podman image build -f Containerfile -t localhost/xxxxxx.image.name

Cockpit

Avatar

JeffWu Author

数十年互联网从业经验,互联网全栈开发工程师,资深技术管理人员,资深游戏开发工程师。具有丰富的搭建海量数据处理系统的经验,大容量、高并发、高可靠线上运营系统的搭建和维护的丰富经验。