2.3. 蓝图自定义和 Containerfile 自定义间等效


下表包含蓝图自定义选项,以及 Containerfile. .Table 中使用的命令。

Blueprint命令说明

distro = "rhel-10."

FROM rhel-bootc:10

[[packages]]

name = "openssh-server" version = "8llowedRegistries"

RUN dnf install &lt ;package name>

[[groups]

name = "anaconda-tools"

RUN dnf group install

[[containers]]

source = "quay.io/rhel/rhel:latest"

RUN podman pull docker.io/library/postgres:alpine

[customizations.kernel]

name = "kernel-debug" append = "nosmt=force"

RUN mkdir -p /usr/lib/bootc/kargs.d RUN cat <<'EOF' >> /usr/lib/bootc/kargs.d/console.toml kargs = ["console=ttyS0,114800n8","kernel-debug"] match-architectures = ["x86_64"] EOF

[customizations.rhsm.config.dnf_plugins.product_id]

enabled = true [customizations.rhsm.config.dnf_plugins.subscription_manager]

enabled = true [customizations.rhsm.config.subscription_manager.rhsm]

manage_repos = true [customizations.rhsm.config.subscription_manager.rhsmcertd]

auto_registration = true

COPY ./rhsm.conf /etc/rhsm/rhsm.conf

[customizations.rpm.import_keys]

files = [ "/etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-18-primary", "/etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-19-primary" ]

RUN mkdir -p /etc/pki/rpm-gpg/ COPY <host_path>/gpg_key /etc/pki/rpm-gpg//gpg_key

[[customizations.sshkey]]

user = "root" key = "PUBLIC SSH KEY"

# SSH keys COPY test.pub container_key.pub RUN mkdir -p .ssh && \ cat container_key.pub >> .ssh/authorized_keys && \ chmod 600 .ssh/authorized_keys && \ rm -f container_path_to_key.pub

[customizations.timezone]

timezone = "US/Eastern" ntpservers = ["0.north-america.pool.ntp.org", "1.north-america.pool.ntp.org"]

RUN ln -sf /usr/share/zoneinfo/Asia/Bangkok /etc/localtime

[customizations.locale]

language = ["en_US.UTF-8"] 键盘 = "us"

RUN cat <<'EOF' >> /etc/locale.conf LANG="en_US.UTF-8" EOF && \ cat <<'EOF' >> /etc/vconsole.conf KEYMAP=us EOF

[customizations.firewall]

ports = ["22:tcp", "80:tcp", "imap:tcp", "53:tcp", "53:udp", "30000-32767:tcp", "30000-32767:udp"]

RUN dnf install -y firewalld && \ dnf clean all && \ firewall-offline-cmd --new-zone=customzone && \ firewall-offline-cmd --zone=customzone --set-description="Custom firewall rules for the container" && \ firewall-offline-cmd --zone=customzone --add-service=ftp && \ firewall-offline-cmd --zone=customzone --add-service=ntp && \ firewall-offline-cmd --zone=customzone --add-service=dhcp && \ firewall-offline-cmd --zone=customzone --add-port=22/tcp && \ firewall-offline-cmd --zone=customzone --add-port=80/tcp && \ firewall-offline-cmd --zone=customzone --add-port=53/tcp && \ firewall-offline-cmd --zone=customzone --add-port=53/udp && \ firewall-offline-cmd --zone=customzone --add-port=30000-32767/tcp && \ firewall-offline-cmd --zone=customzone --add-port=30000-32767/udp && \ firewall-offline-cmd --set-default-zone=customzone

[[customizations.directories]]

path = "/etc/ &lt;dir-name> " mode = "0755" user = "root" group = "root" ensure_parents = false

#directory: RUN mkdir /etc/ <dir > RUN chown -R admin:wheel /etc/ <dir> && amp; \ chmod -R 644 /etc/ <dir > #Files: RUN touch /etc/ <myfile > RUN chown :widget /etc/ <myfile> && amp; \ chmod 600 /etc/ <myfile>

[customizations]

installation_device = "/dev/sda"

RUN mkdir -p /usr/lib/bootc/kargs.d && \ cat <<'EOF' >> /usr/lib/bootc/kargs.d/console.toml kargs = ["inst.device=/dev/sda"] EOF

[customizations.ignition.embedded]

config = "eyJpZ25pdG…​.xIn1dfX0="

RUN mkdir -p /usr/lib/bootc/kargs.d && \ cat <<'EOF' >> /usr/lib/bootc/kargs.d/console.toml kargs = ["ignition.config.url=http://192.168.122.1/fiot.ign","rd.neednet=1"] EOF

[customizations.fdo]

manufacturing_server_url = "http://192.168.122.199:8080" diun_pub_key_insecure = "true" di_mfg_string_type_mac_iface = "enp2s0"

RUN dnf install -y fdo-init fdo-client && \ systemctl enable fdo-client-linuxapp.service

[customizations.openscap]

datastream = "/usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml" profile_id = "xccdf_org.ssgproject.content_profile_cis"

[customizations.openscap.json_tailoring] profile_id = " &lt;name-of-profile-used-in-json-tailoring&gt;-file" filepath = "/some/path/tailoring-file.json"

[[customizations.files]] path = "/the/path/tailoring-file.json" data = " <json-tailoring-file-contents>"

RUN dnf install -y openscap-utils && \ autotailor --output /some/path/tailoring-file.json \ --new-profille-id xccdf_org.ssgproject.content_profile_cis

[customizations]

fips = true

RUN mkdir -p /usr/lib/bootc/kargs.d && \ cat <<'EOF' >> /usr/lib/bootc/kargs.d/01-fips.toml kargs = ["fips=1"] EOF && \ update-crypto-policies --no-reload --set FIPS

2.3.1. 使用 RHEL 的镜像模式创建类似的 RHEL for Edge 镜像

要使用 RHEL 的镜像模式创建边缘镜像,您必须手动安装一些与 OSTree 提交通用的软件包。大多数软件包都是 bootc 镜像的一部分,但有几个缺少的软件包,例如:

  • clevis
  • clevis-dracut
  • clevis-luks
  • greenboot
  • greenboot-default-health-checks
  • fdo-client
  • fdo-owner-cli

要安装缺少的软件包并创建类似的 RHEL for Edge 镜像,请按照以下步骤执行:

先决条件

  • 基于现有 RHEL for Edge rpm-ostree 部署的系统。

流程

  1. 使用以下内容创建一个 Containerfile :

    FROM registry.io.redhat.com/rhel10/rhel-bootc:latest
    
    RUN dnf install -y  \
        clevis  \
        clevis-dracut  \
        clevis-luks  \
        greenboot  \
        greenboot-default-health-checks  \
        fdo-client  \
        fdo-owner-cli
    # (Optionl) Extra packages often used in edge
    # RUN dnf install -y
    #     dracut-config-generic  \
    #     platform-python  \
    #     pinentry  \
    #     firewalld  \
    #     iptables  \
    #     NetworkManager-wifi  \
    #     NetworkManager-wwan  \
    #     wpa_supplicant  \
    #     traceroute  \
    #     rootfiles  \
    #     policycoreutils-python-utils  \
    #     setools-console  \
    #     rsync  \
    #     usbguard
    RUN systemctl enable NetworkManager.service  \
        greenboot-grub2-set-counter.service  \
        greenboot-grub2-set-success.service  \
        greenboot-healthcheck.service  \
        greenboot-rpm-ostree-grub2-check-fallback.service  \
        greenboot-status.service  \
        greenboot-task-runner.service
        redboot-auto-reboot.service  \
        redboot-task-runner.service"
    Copy to Clipboard
  2. 构建类似的 RHEL for Edge 自定义 bootc 镜像:

    $ podman build -t quay.io/<namespace>/<image>:<tag> .
    Copy to Clipboard
  3. 可选:推送镜像:

    $ podman push quay.io/<namespace>/<image>:<tag>
    Copy to Clipboard

验证

  • 列出所有镜像:

    $ podman images
    Copy to Clipboard
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat