第 4 章 在 RHEL 的 Image Mode 中使用命令行助手组件功能


您可以在容器构建和运行时使用 RHEL 的 Image Mode 中的命令行助手组件功能。该助手在 x86_64aarch64 构架中维护只读文件系统安全性的同时,执行系统任务。

先决条件

  • container-tools 元数据软件包已安装。
  • 您有一个订阅的 RHEL 系统。如需更多信息,请参阅 RHEL 系统注册入门 文档。

流程

  1. 创建一个 Containerfile

    $ cat Containerfile
    FROM registry.redhat.io/rhel10/rhel-bootc:latest
    RUN <<EORUN
    set -euxo pipefail
    dnf install -y command-line-assistant
    dnf clean all
    rm -rf /var/cache/dnf/
    bootc container lint
    EORUN
  2. 使用当前目录中的 Containerfile 构建 <image> 镜像:

    $ podman build -t quay.io/<namespace>/<image>:<tag> .
  3. 从容器镜像构建磁盘镜像。以下示例创建 QCOW2 镜像:

    $ sudo podman run \
        --rm \
        -it \
        --privileged \
        --pull=newer \
        --security-opt label=type:unconfined_t \
        -v ./config.toml:/config.toml:ro \
        -v ./output:/output \
        -v /var/lib/containers/storage:/var/lib/containers/storage \
        registry.redhat.io/rhel10/bootc-image-builder:latest \
        --type qcow2 \
        --config /config.toml \
        quay.io/<namespace>/<image>:<tag>
    • <namespace& gt; : 您的容器 registry 命名空间。
    • <image& gt; : 您的镜像名称。
    • <tag > : 您的镜像标签,如 latest。
  4. 使用 QCOW2 磁盘镜像引导机器。具体步骤请参阅 使用带有 QCOW2 磁盘镜像的 KVM 部署容器镜像

验证

  • 通过运行命令行助手来验证安装是否正常工作。例如:

    $ c "How to deploy a QCOW2 disk image?"

    输出类似以下示例:

    +*+ Asking RHEL Lightspeed
    
    To deploy a QCOW2 disk image....
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

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

让开源更具包容性

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

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部