用户操作
在允许没有root特权的用户运行Podman之前,管理员必须安装或构建Podman并完成以下配置
cgroup V2Linux内核功能允许用户限制普通用户容器可以使用的资源,如果使用cgroupV2启用了运行Podman的Linux发行版,则可能需要更改默认的OCI运行时。某些较旧的版本runc不适用于cgroupV2,必须切换到备用OCI运行时crun。
[root@localhost ~]# yum -y install crun //centos8系统自带
[root@localhost ~]# cd /usr/share/containers/
[root@localhost containers]# ls
containers.conf mounts.conf seccomp.json selinux
[root@localhost containers]# vim containers.conf
#
runtime = "crun"
#runtime = "runc"
[root@localhost ~]# podman run -d --name web -p 80:80 httpd
9f17e55aee35d1f1da01f7f5edb0ca875d56b1cb7f70d6a6a9796885c35a4212
[root@localhost ~]# podman inspect web | grep crun
"OCIRuntime": "crun",
[root@localhost ~]#
安装slirp4netns和fuse-overlayfs
在普通用户环境中使用Podman时,建议使用fuse-overlayfs而不是VFS文件系统,至少需要版本0.7.6。现在新版本默认就是了。
[root@localhost ~]# yum -y install slirp4netns
[root@localhost ~]# yum -y install fuse-overlayfs
[root@localhost ~]# rpm -qa | grep slirp4netns
slirp4netns-1.1.8-2.module_el8.7.0+1106+45480ee0.x86_64
[root@localhost ~]# rpm -qa | grep fuse-overlayfs
fuse-overlayfs-1.8.2-1.module_el8.7.0+1106+45480ee0.x86_64
[root@localhost ~]# cd /etc/containers/
[root@localhost containers]# ls
certs.d oci policy.json registries.conf registries.conf.d registries.d storage.conf
[root@localhost containers]# vim storage.conf
# directly.
mount_program = "/usr/bin/fuse-overlayfs" //取消注释
[root@localhost ~]# which fuse-overlayfs
/usr/bin/fuse-overlayfs
/ etc / subuid和/ etc / subgid配置
Podman要求运行它的用户在/ etc / subuid和/ etc / subgid文件中列出一系列UID,shadow-utils或newuid包提供这些文件
[root@localhost ~]# useradd yuli
[root@localhost ~]# cat /etc/subuid
yuli:100000:65536
[root@localhost ~]# cat /etc/subgid
yuli:100000:65536
[root@localhost ~]# vim /etc/sysctl.conf
net.ipv4.ping_group_range=0 300000 //大于100000这个就表示tom可以操作podman
[root@localhost ~]# sysctl -p #打印
这个文件的格式是 USERNAME:UID:RANGE中/etc/passwd或输出中列出的用户名getpwent。
- 为用户分配的初始 UID。
- 为用户分配的 UID 范围的大小。
该usermod程序可用于为用户分配 UID 和 GID。
[root@localhost ~]# useradd op
[root@localhost ~]# cat /etc/subgid
yuli:100000:65536
op:165536:65536
[root@localhost ~]# usermod --del-subuids 165536-231072 --del-subgids 165536-231072 op
[root@localhost ~]# cat /etc/subgid
yuli:100000:65536
[root@localhost ~]# usermod --add-subuids 200000-201000 --add-subgids 200000-201000 op
[root@localhost ~]# cat /etc/subgid
yuli:100000:65536
op:200000:1001
用户配置文件
三个