podman的简介和安装

1. 什么是podman?

Podman 是一个无守护进程的容器引擎,用于在 Linux 系统上开发、管理和运行 OCI 容器。容器可以以 root 或无根模式运行。

Podman 是一个开源项目,可在大多数 Linux 平台上使用并驻留在GitHub上。Podman 是一个无守护进程的容器引擎,用于在 Linux 系统上开发、管理和运行 Open Container Initiative (OCI) 容器和容器映像。

Podman 还提供了一个套接字激活的 REST API 服务,以允许远程应用程序启动按需容器。这个 REST API 还支持 Docker API,允许 docker-py 和 docker-compose 的用户与 Podman 作为服务进行交互。

Podman 服务仅运行在 Linux 平台上,但 Podman 远程 REST API 客户端存在于 Mac 和 Windows 平台上,并且可以通过 ssh 与运行在 Linux 机器或 VM 上的 Podman 服务进行通信。

2. podman安装

podman可以在windows、linux、mac等众多平台上安装
podman官网:https://podman.io/

podman 在 CentOS 7 的默认 Extras 存储库中可用,在 CentOS 8 和 Stream 的 AppStream 存储库中可用。

[root@localhost ~]# yum -y install podman
[root@localhost ~]# rpm -qa | grep podman
podman-1.6.4-29.el7_9.x86_64

//可以给podman定义别名
[root@localhost ~]# alias docker=podman
[root@localhost ~]# docker images
REPOSITORY   TAG   IMAGE ID   CREATED   SIZE
[root@localhost ~]# 

3. poman 的常用命令

[root@localhost ~]#  podman search nginx
INDEX        NAME                                                           DESCRIPTION                                       STARS   OFFICIAL   AUTOMATED
redhat.com   registry.access.redhat.com/ubi8/nginx-120                      Platform for running nginx 1.20 or building ...   0                  
redhat.com   registry.access.redhat.com/ubi8/nginx-118                      Platform for running nginx 1.18 or building ...   0                  
redhat.com   registry.access.redhat.com/rhscl/nginx-110-rhel7               Nginx container image that delivers an nginx...   0                  
redhat.com   registry.access.redhat.com/rhscl/nginx-16-rhel7                Nginx 1.6 server and a reverse proxy server       0                  
redhat.com   registry.access.redhat.com/rhscl/nginx-18-rhel7                Nginx 1.8 server and a reverse proxy server       0                  
redhat.com   registry.access.redhat.com/rhscl/nginx-112-rhel7               Nginx is a web server and a reverse proxy se...   0                  
redhat.com   registry.access.redhat.com/ubi7/nginx-118                      Platform for running nginx 1.18 or building ...   0                  
redhat.com   registry.access.redhat.com/rhscl/nginx-114-rhel7               Nginx is a web server and a reverse proxy se...   0                  
redhat.com   registry.access.redhat.com/3scale-amp23/apicast-gateway         3scale's API gateway (APIcast) 
  .......省略N行

//使用过滤器增强搜索 (--filter=is-official 过滤官方镜像)
[root@localhost ~]# podman search nginx --filter=is-official
INDEX       NAME                      DESCRIPTION                STARS   OFFICIAL   AUTOMATED
docker.io   docker.io/library/nginx   Official build of Nginx.   15928   [OK]       
[root@localhost ~]# 

//下载(拉取)镜像
[root@localhost ~]# podman pull docker.io/library/nginx
Trying to pull docker.io/library/nginx...
Getting image source signatures
Copying blob 881ff011f1c9 done  
Copying blob ed835de16acd done  
Copying blob 44be98c0fab6 done  
Copying blob 21e0df283cd6 done  
Copying blob e5ae68f74026 done  
Copying blob 77700c52c969 done  
Copying config f652ca386e done  
Writing manifest to image destination
Storing signatures
f652ca386ed135a4cbe356333e08ef0816f81b2ac8d0619af01e2b256837ed3e
[root@localhost ~]# docker images
REPOSITORY                TAG      IMAGE ID       CREATED       SIZE
docker.io/library/nginx   latest   f652ca386ed1   12 days ago   146 MB
[root@localhost ~]# 

//运行容器
[root@localhost ~]# podman run -d -p 80:80 docker.io/library/nginx:latest
5d3e7331a604bc22679f41474a01f4225d67608a8f3e5046e419dc3137abef78
[root@localhost ~]# docker ps
CONTAINER ID  IMAGE                           COMMAND               CREATED        STATUS            PORTS               NAMES
5d3e7331a604  docker.io/library/nginx:latest  nginx -g daemon o...  6 seconds ago  Up 5 seconds ago  0.0.0.0:80->80/tcp  nostalgic_ride
[root@localhost ~]# docker ps -a
CONTAINER ID  IMAGE                           COMMAND               CREATED         STATUS             PORTS               NAMES
5d3e7331a604  docker.io/library/nginx:latest  nginx -g daemon o...  12 seconds ago  Up 12 seconds ago  0.0.0.0:80->80/tcp  nostalgic_ride
[root@localhost ~]# 

//测试容器
[root@localhost ~]# curl 192.168.8.128
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
[root@localhost ~]# 

检查正在运行的容器,以查找有关其自身的元数据和详细信息。 将提供许多有用的信息,如环境变量,网络设置或分配的资源。podman inspect

由于容器在root模式下运行,因此会为容器分配 IP 地址

//grep -i ipaddress(忽略大小写)
[root@localhost ~]# podman inspect -l |grep -i ipaddress
            "SecondaryIPAddresses": null,
            "IPAddress": "10.88.0.2",
[root@localhost ~]# 

//查看容器的日志
[root@localhost ~]# podman logs -l
/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
2021/12/14 12:44:48 [notice] 1#1: using the "epoll" event method
2021/12/14 12:44:48 [notice] 1#1: nginx/1.21.4
2021/12/14 12:44:48 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6) 
2021/12/14 12:44:48 [notice] 1#1: OS: Linux 3.10.0-862.el7.x86_64
2021/12/14 12:44:48 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2021/12/14 12:44:48 [notice] 1#1: start worker processes
2021/12/14 12:44:48 [notice] 1#1: start worker process 32
2021/12/14 12:44:48 [notice] 1#1: start worker process 33
2021/12/14 12:44:48 [notice] 1#1: start worker process 34
2021/12/14 12:44:48 [notice] 1#1: start worker process 35
192.168.8.128 - - [14/Dec/2021:12:46:20 +0000] "GET / HTTP/1.1" 200 615 "-" "curl/7.29.0" "-"
[root@localhost ~]# 

//查看容器的 pids
[root@localhost ~]# podman top -l
USER    PID   PPID   %CPU    ELAPSED           TTY   TIME   COMMAND
root    1     0      0.000   5m56.761146184s   ?     0s     nginx: master process nginx -g daemon off;
nginx   32    1      0.000   5m56.761232256s   ?     0s     nginx: worker process
nginx   33    1      0.000   5m56.76128208s    ?     0s     nginx: worker process
nginx   34    1      0.000   5m56.761322851s   ?     0s     nginx: worker process
nginx   35    1      0.000   5m56.761372584s   ?     0s     nginx: worker process
[root@localhost ~]# 

//停止容器
[root@localhost ~]# podman stop -l
5d3e7331a604bc22679f41474a01f4225d67608a8f3e5046e419dc3137abef78
[root@localhost ~]# podman ps 
CONTAINER ID  IMAGE  COMMAND  CREATED  STATUS  PORTS  NAMES
[root@localhost ~]# podman ps -a
CONTAINER ID  IMAGE                           COMMAND               CREATED        STATUS                     PORTS               NAMES
5d3e7331a604  docker.io/library/nginx:latest  nginx -g daemon o...  7 minutes ago  Exited (0) 17 seconds ago  0.0.0.0:80->80/tcp  nostalgic_ride
[root@localhost ~]# 


//删除容器
[root@localhost ~]# podman rm -l
5d3e7331a604bc22679f41474a01f4225d67608a8f3e5046e419dc3137abef78
[root@localhost ~]# podman ps -a
CONTAINER ID  IMAGE  COMMAND  CREATED  STATUS  PORTS  NAMES
[root@localhost ~]# 

//镜像修改标签(改名)
[root@localhost ~]# podman images
REPOSITORY                TAG      IMAGE ID       CREATED       SIZE
docker.io/library/nginx   latest   f652ca386ed1   12 days ago   146 MB
[root@localhost ~]# podman tag docker.io/library/nginx:latest docker.io/pengyudong/nginx:v1.0
[root@localhost ~]# podman images
REPOSITORY                   TAG      IMAGE ID       CREATED       SIZE
docker.io/library/nginx      latest   f652ca386ed1   12 days ago   146 MB
docker.io/pengyudong/nginx   v1.0     f652ca386ed1   12 days ago   146 MB
[root@localhost ~]# 

4. 普通用户使用podman的方式

在允许没有root特权的用户运行Podman之前,管理员必须安装或构建Podman并完成以下配置

cgroup V2Linux内核功能允许用户限制普通用户容器可以使用的资源,如果使用cgroup V2启用了运行Podman的Linux发行版,则可能需要更改默认的OCI运行时。某些较旧的版本runc不适用于cgroup V2,必须切换到备用OCI运行时crun。

[root@localhost ~]# yum -y install crun     # centos8系统自带

[root@localhost ~]# vim /usr/share/containers/containers.conf 
......
446 # Default OCI runtime
447 # 
448 runtime = "crun"      # 取消注释并将值改为crun
......

[root@localhost ~]# podman run -d -p 80 docker.io/library/nginx
81462774ef3a27079293143a15b361a9672100e44868ac3d72ec238142ef5f84

[root@localhost ~]# podman inspect -l | grep crun
        "OCIRuntime": "crun",
            "crun",
[root@localhost ~]# podman run -d -p 80 docker.io/library/nginx
81462774ef3a27079293143a15b361a9672100e44868ac3d72ec238142ef5f84

[root@localhost ~]# podman inspect -l | grep crun
        "OCIRuntime": "crun",
            "crun",

//slirp4netns
[root@localhost ~]# rpm -qa| grep slirp4netns
slirp4netns-1.1.8-1.module_el8.6.0+926+8bef8ae7.x86_64

在普通用户环境中使用Podman时,建议使用fuse-overlayfs而不是VFS文件系统,至少需要版本0.7.6。现在新版本默认就是

//安装fuse-overlayfs
[root@localhost ~]# rpm -qa |grep fuse-overlayfs
fuse-overlayfs-1.7.1-1.module_el8.6.0+926+8bef8ae7.x86_64

[root@localhost ~]# vim /etc/containers/storage.conf
......
77 mount_program = "/usr/bin/fuse-overlayfs"     # 取消注释
......

/etc/subuid和/etc/subgid配置

Podman要求运行它的用户在/etc/subuid和/etc/subgid文件中列出一系列UID,shadow-utils或newuid包提供这些文件

//centos 8 自带的有这个包,再安装一次就更新了这个包
[root@localhost ~]# yum -y install shadow-utils

可以在 /etc/subuid 和 /etc/subgid 查看,每个用户的值必须唯一且没有任何重叠。

[root@localhost ~]# podman ps
CONTAINER ID  IMAGE                           COMMAND               CREATED         STATUS             PORTS               NAMES
fec0a6296d77  docker.io/library/nginx:latest  nginx -g daemon o...  10 minutes ago  Up 10 minutes ago  0.0.0.0:80->80/tcp  nginx
[root@localhost ~]# podman exec -it nginx /bin/bash

root@fec0a6296d77:/# id
uid=0(root) gid=0(root) groups=0(root)
root@fec0a6296d77:/# cat /etc/subuid 
root@fec0a6296d77:/# useradd pyd
root@fec0a6296d77:/# cat /etc/subuid
test:100000:65536

该文件的格式为USERNAME:UID:RANGE

  • 在/ etc / passwd或getpwent中列出的用户名。
  • 为用户分配的初始uid。
  • 为用户分配的UID范围的大小

用户的配置文件

三个主要的配置文件是container.conf,storage.conf和registries.conf。用户可以根据需要修改这些文件。

container.conf

Podman读取时,按照循序来了,当前面一位找不到时,就去找下一个

1./usr/share/containers/containers.conf
2./etc/containers/containers.conf
3.$HOME/.config/containers/containers.conf

storage.conf
storge.conf则是

1./etc/containers/storage.conf
2.$HOME/.config/containers/storage.conf

在普通用户中/etc/containers/storage.conf的一些字段将被忽略

graphroot=``""`` ``container storage graph ``dir` `(default: ``"/var/lib/containers/storage"``)`` ``Default directory to store all writable content created by container storage programs.` `runroot=``""`` ``container storage run ``dir` `(default: ``"/run/containers/storage"``)`` ``Default directory to store all temporary writable content created by container storage programs.

在普通用户中这些字段默认

graphroot=``"$HOME/.local/share/containers/storage"``runroot=``"$XDG_RUNTIME_DIR/containers"

registries.conf
配置按此顺序读入,这些文件不是默认创建的,可以从/usr/share/containers或复制文件/etc/containers并进行修改

1./etc/containers/registries.conf
2./etc/containers/registries.d/*
3.HOME/.config/containers/registries.conf

授权文件
podman login 登录,默认授权文件在${XDG_RUNTIME_DIR}/containers/auth.json

[root@localhost ~]# cat /run/user/0/containers/auth.json 
{
	"auths": {
		"docker.io": {
			"auth": "********************="
		}
	}
}
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
### 回答1: windowsserver2016-sxs.zip是一个压缩文件,其中包含Windows Server 2016操作系统的可选功能和语言资源。SXS表示"Side-by-Side",意味着这些功能和资源可以与已安装的操作系统并存。 Windows Server 2016是微软发布的一款服务器操作系统,提供了许多功能和工具,可以用于构建和管理企业级网络和服务。然而,并非所有功能都默认安装在操作系统中,有些功能需要根据用户的需求进行手动安装。为了方便用户选择和安装这些功能,微软将它们打包并放在了windowsserver2016-sxs.zip这个压缩文件中。 用户可以通过解压windowsserver2016-sxs.zip文件,将其中的内容复制到系统的相应目录中,以启用所需的功能和语言资源。这些功能可能包括网络服务、安全功能、远程管理工具、存储和文件服务等。而语言资源则包括多种语言的界面和帮助文件,可以使操作系统的界面显示为用户所选择的语言。 通过提供windowsserver2016-sxs.zip,微软让用户能够根据自己的需要定制操作系统,仅安装所需的功能,以减少系统资源的浪费和提高系统的性能。同时,用户也可以方便地切换和添加多种语言的支持,以满足不同地区和使用环境的需求。 总而言之,windowsserver2016-sxs.zip是Windows Server 2016操作系统可选功能和语言资源的压缩文件,用户可以通过解压和安装其中的内容来定制和增强操作系统的功能。 ### 回答2: windowsserver2016-sxs.zip是Windows Server 2016操作系统的一个压缩文件。在Windows操作系统中,经常会使用SxS(Side-by-Side)来管理和支持不同版本的共存。SxS文件夹是一个特殊的文件夹,用于存放不同版本的系统组件和应用程序所需的文件。 这个windowsserver2016-sxs.zip文件很可能是用于安装和维护Windows Server 2016操作系统的一些额外组件和功能。通过解压该压缩文件,可以获取一些额外的功能和更新补丁,以满足操作系统的特定需求。 Windows Server 2016是微软推出的一款面向企业和组织的服务器操作系统。它具有许多新的功能和改进,如更好的安全性、虚拟化支持、容器化应用程序支持以及更强大的云计算功能。通过安装windowsserver2016-sxs.zip文件中的组件,可以扩展操作系统的功能,提供更多的特性和选项。 要安装windowsserver2016-sxs.zip文件中的组件,您需要先解压缩该文件,然后根据提供的安装指南进行安装。通常,您可以在操作系统的设置中找到相应的安装向导或菜单选项,以便安装或启用specific components and features from the windowsserver2016-sxs.zip file. 总的来说,windowsserver2016-sxs.zip是一个用于扩展和定制Windows Server 2016操作系统的压缩文件。通过安装其中的组件,您可以为您的服务器系统添加更多的功能和特性,以满足特定的需求或应用场景。 ### 回答3: windowsserver2016-sxs.zip是Windows Server 2016操作系统的一个压缩文件。SxS代表"Side by Side",指的是在同一系统中运行不同版本的软件组件。这个zip文件包含了Windows Server 2016操作系统的SxS文件夹。SxS文件夹包含了操作系统所需的各种组件、库和驱动程序。 这个zip文件通常用于安装和更新Windows Server 2016操作系统时使用。当需要安装或更新新的功能或驱动程序时,操作系统会从SxS文件夹中查找所需的文件。通过使用这种方式,不同版本的软件组件可以平行安装在同一系统中,而不会相互干扰。 要使用这个zip文件,我们可以将其解压缩到合适的目录,并将其路径添加到操作系统的环境变量中。这样,当操作系统需要使用SxS文件夹中的文件时,就可以自动找到它们。 总之,windowsserver2016-sxs.zip是Windows Server 2016操作系统中SxS文件夹的压缩文件,包含了操作系统所需的各种组件、库和驱动程序。通过使用这个zip文件,我们可以方便地安装和更新操作系统的功能和驱动程序。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

彭宇栋

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值