如何在Fedora中结合权能使用Podman

在 Fedora 中结合权能使用 Podman,可以使用 POSIX 权能 Capability 来保护 Podman 容器的安全。

Fedora与Podman简介

Fedora是一个基于RPM(Red Hat Package Manager)的免费开源Linux发行版,由Red Hat公司赞助并由全球志愿者贡献,它以稳定性和安全性著称,适用于服务器、桌面和云环境,而Podman是一个用于构建和管理容器的工具,它允许开发者使用沙箱技术在同一个系统上运行多个隔离的容器,Podman可以在多种操作系统上运行,包括Fedora。

在Fedora中安装Podman

1、更新系统软件包列表:

如何在Fedora中结合权能使用Podman

sudo dnf update

2、安装必要的依赖项:

sudo dnf install -y libffi-devel docker openssl-devel python-devel

3、下载并安装Podman:

curl -Lo podman https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_18.04/Packages/podman-4.2.0-1.x86_64.rpm
sudo dnf -y install ./podman-4.2.0-1.x86_64.rpm

4、验证Podman是否安装成功:

podman --version

配置Fedora中的用户组和权限

为了能够在所有用户下使用Podman,我们需要创建一个新的用户组,并将该用户组添加到wheel组中,这样用户就可以使用sudo命令来执行Podman相关操作,我们需要为新创建的用户组设置密码策略。

如何在Fedora中结合权能使用Podman

1、创建新的用户组:

sudo groupadd podman_users

2、将新创建的用户组添加到wheel组中:

sudo usermod -aG wheel podman_users <username>

3、为新创建的用户组设置密码策略:

sudo visudo

在打开的文件中添加以下内容:

如何在Fedora中结合权能使用Podman

%podman_users ALL=(ALL) NOPASSWD: ALL

保存并退出,现在,新创建的用户组的所有成员都可以在不输入密码的情况下使用Podman。

测试Podman在Fedora中的使用

1、创建一个名为test-podman.txt的文本文件,包含以下内容:

FROM ubuntu:latest as builder
RUN apt-get update && apt-get install -y git python3 python3-pip build-essential curl wget tar unzip || exit 1; 
WORKDIR /app; 
COPY *.sh /app; 
RUN chmod +x /app/*.sh; 
CMD ["sh", "run.sh"]

2、在当前目录下创建一个名为run.sh的脚本文件,包含以下内容:

!/bin/bash -euo pipefail  https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/  [BEFORE]  https://stackoverflow.com/questions/49752530/why-doesnt-set-euxo-work-on-my-bash49752530 [AFTER]  https://stackoverflow.com/questions/65978870/how-to-fix-set-euxo-pipefail-is-not-defined65978870  https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/  [BEFORE]  https://stackoverflow.com/questions/49752530/why-doesnt-set-euxo-work-on-my-bash49752530 [AFTER]  https://stackoverflow.com/questions/65978870/how-to-fix-set-euxo-pipefail-is-not-defined65978870  https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/  [BEFORE]  https://stackoverflow.com/questions/49752530/why-doesnt-set-euxo-work-on-my-bash49752530 [AFTER]  https://stackoverflow.com/questions/65978870/how-to-fix-set-euxo-pipefail-is-not-defined65978870  https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/  [BEFORE]  https://stackoverflow.com/questions/49752530/why-doesnt-set-euxo-work-on-my-bash49752530 [AFTER]  https://stackoverflow.com/questions/65978870/how-to-fix-set-euxo-pipefail-is-not-defined65978870  https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/  [BEFORE]  https://stackoverflow.com/questions/49752530/why-doesnt-set-euxo-work-on-my-bash49752530 [AFTER]  https://stackoverflow.com/questions/65978870/how-to-fix-set-euxo

原创文章,作者:酷盾叔,如若转载,请注明出处:https://www.kdun.com/ask/124746.html

(0)
酷盾叔订阅
上一篇 2023-12-29 22:30
下一篇 2023-12-29 22:35

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

云产品限时秒杀。精选云产品高防服务器,20M大带宽限量抢购  >>点击进入