8.4. bootc イメージをゼロから生成する


Red Hat Enterprise Linux アプリケーションのための、効率的でセキュアな基盤を構築するために、カスタムの最小限のベースイメージを生成します。最小限のベースイメージを作成することで、最終的なデプロイメントに必要不可欠なパッケージのみが含まれるようにして、システム全体のフットプリントと攻撃対象領域を削減できます。

前提条件

  • container-tools メタパッケージがインストールされている。

手順

  • Containerfile を作成します。以下に例を示します。

    # The following example reuses the default base image as a "builder" image. Optionally,  you can use the commented instructions to configure or override the RPM repositories in /etc/yum.repos.d to, for example, refer to pinned versions
    FROM registry.redhat.io/rhel10/rhel-bootc:latest as builder
    # RUN rm -rf /etc/yum.repos.d/*
    # COPY mycustom.repo /etc/yum.repos.d
    RUN dnf repolist && /usr/libexec/bootc-base-imagectl build-rootfs --manifest=minimal /target-rootfs
    # Create a new, empty image from scratch.
    FROM scratch
    # Copy the root file system built in the previous step into this image.
    COPY --from=builder /target-rootfs/ /
    # You can make arbitrary changes such as copying the systemd units and other tweaks from the baseconfig container image. This example uses the heredocs syntax, to improve and make it easy to add complex instructions, and install critical components
    RUN <<EORUN
    set -xeuo pipefail
    # Install networking support and SSH which are not in minimal
    dnf -y install NetworkManager openssh-server
    dnf clean all
    rm /var/{log,cache,lib}/* -rf
    bootc container lint
    EORUN
    # This label is required
    LABEL containers.bootc 1
    LABEL ostree.bootable 1
    # These labels are optional but useful if you want to keep the default of running under systemd when run as a container image.
    STOPSIGNAL SIGRTMIN+3
    CMD ["/sbin/init"]

次のステップ

  • Containerfile を作成すると、単一の tar ファイルの大きなレイヤーを持つイメージが取得されます。レジストリーへのプッシュ、クライアントへのプルなどのすべての変更により、単一の大きな tar ファイルがコピーされ、コンテナーイメージのサイズが増加します。作成したコンテナーイメージを小さいバージョンに最適化できます。
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

Red Hat ドキュメントについて

Legal Notice

Theme

© 2026 Red Hat
トップに戻る