Podman 介绍
What is Podman?
Podman 是一个基于 Linux
系统的 daemon-less
的容器引擎。 可以用来开发,管理和运行 OCI
标准的容器. podman
可以运行在root或者非root用户模式。
Podman 是 Red Hat 在2018年推出的,源代码开放。
官方网站 https://podman.io/
OCI https://opencontainers.org/
和 docker 的区别
- 最主要的区别是podman是Daemonless的,而Docker在执行任务的时候,必须依赖于后台的docker daemon(最主要的区别)
- podman不需要使用root用户或者root权限,所以更安全。(最主要的区别)
- podman可以创建pod,pod的概念和Kubernetes 里定义的pod类似
- podman运行把镜像和容器存储在不同的地方,但是docker必须存储在docker engineer所在的本地
- podman是传统的fork-exec 模式,而docker是 client-server 架构
框架区别
Docker架构
Podman架构
Podman 的安装
安装文档地址:https://podman.io/getting-started/installation
Podman是个Linux程序,不能在Windows上运行,但是可以运行客户端,发送到Linux服务端操作。
Windows 使用
Podman是一个运行Linux容器的工具。您可以从 Windows 桌面执行此操作,只要您有权访问在主机上的 VM 内运行或通过网络可用的 linux 机箱即可。您需要安装远程客户端,然后在 podman-remote.conf 文件中设置 ssh 连接信息。Podman也可以在Windows子系统Linux系统上运行,请查看下面的链接以查看如何完成此操作的说明。
远程客户端
- 适用于 Windows 的最新远程客户端
Windows Subsystem for Linux (WSL) 2.0
- 如何使用WSL2在Windows上运行Podman
Linux 发行版
Arch Linux & Manjaro Linux
sudo pacman -S podman
CentOS
Podman 在 CentOS 7 的默认 Extras 存储库中可用,在 CentOS 8 和 Stream 的 AppStream 存储库中可用。
sudo yum -y install podman
Debian
podman 软件包在 Debian 11 (Bullseye) 存储库及更高版本中可用。
sudo apt-get -y install podman
Ubuntu
podman 包在 Ubuntu 20.10 及更高版本的官方存储库中可用。
# Ubuntu 20.10 and newer
sudo apt-get -y update
sudo apt-get -y install podman
源码安装
仔细检查golang版本是否足够新(即2022年1月版本1.16)。需要x或更高。当前的最低要求版本总是可以在go中找到。mod文件。如果需要,golang套件可在https://golang.org/dl/.或者,go也可以从源代码构建,如下所示(保留系统go安装会很有帮助,以避免必须引导go:go版本)
export GOPATH=~/go
git clone https://go.googlesource.com/go $GOPATH
cd $GOPATH
cd src
./all.bash
export PATH=$GOPATH/bin:$PATH
首先,确保在$PATH上首先找到的值高于1.12.x。如果需要,上面的说明将帮助您编译更新版本的Go。然后我们就可以构建Podman:go版本了
git clone https://github.com/containers/podman/
cd podman
make BUILDTAGS="selinux seccomp"
sudo make install PREFIX=/usr
构建标签
除此以外,如果您不想使用seccomp
或selinux
支持构建Podman,可以在运行make时添加。BUILDTAGS=“”
make BUILDTAGS=""
sudo make install
快速上手
安装一个Nginx
和docker
的命令一样
甚至可以把podman
的关键词,改成docker
启动Nginx容器
[root@python ~]# podman image pull docker.io/library/nginx
Trying to pull docker.io/library/nginx...
Getting image source signatures
Copying blob 091c283c6a66 skipped: already exists
Copying blob 55de5851019b skipped: already exists
Copying blob 5eb5b503b376 skipped: already exists
Copying blob 1ae07ab881bd skipped: already exists
Copying blob 78091884b7be skipped: already exists
Copying blob b559bad762be [--------------------------------------] 0.0b / 0.0b
Copying config c316d5a335 done
Writing manifest to image destination
Storing signatures
c316d5a335a5cf324b0dc83b3da82d7608724769f6454f6d9a621f3ec2534a5a
[root@python ~]# podman image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/nginx latest c316d5a335a5 32 hours ago 146 MB
[root@python ~]# podman container run docker.io/library/nginx
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2022/01/27 18:04:36 [notice] 1#1: using the "epoll" event method
2022/01/27 18:04:36 [notice] 1#1: nginx/1.21.6
2022/01/27 18:04:36 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6)
2022/01/27 18:04:36 [notice] 1#1: OS: Linux 3.10.0-693.11.1.el7.x86_64
2022/01/27 18:04:36 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2022/01/27 18:04:36 [notice] 1#1: start worker processes
2022/01/27 18:04:36 [notice] 1#1: start worker process 30