1.2. Building the bootc image


Build your Red Hat Enterprise Linux (RHEL) that contains MicroShift as a bootable container image by using a Containerfile.

重要

Image mode for RHEL is Technology Preview. Using a bootc image in production environments is not supported.

Prerequisites

  • A Red Hat Enterprise Linux (RHEL) 9.4 host with an active Red Hat subscription for building MicroShift bootc images and running containers.
  • You are logged into the RHEL 9.4 host using the user credentials that have sudo permissions.
  • The rhocp and fast-datapath repositories are accessible in the host subscription. The repositories do not necessarily need to be enabled on the host.
  • You have a remote registry such as {quay} for storing and accessing bootc images.

Procedure

  1. Create a Containerfile that includes the following instructions:

    Example Containerfile for RHEL image mode

    FROM registry.redhat.io/rhel9/rhel-bootc:9.4
    
    ARG USHIFT_VER=4.17
    RUN dnf config-manager \
            --set-enabled rhocp-${USHIFT_VER}-for-rhel-9-$(uname -m)-rpms \
            --set-enabled fast-datapath-for-rhel-9-$(uname -m)-rpms
    RUN dnf install -y firewalld microshift && \
        systemctl enable microshift && \
        dnf clean all
    
    # Create a default 'redhat' user with the specified password.
    # Add it to the 'wheel' group to allow for running sudo commands.
    ARG USER_PASSWD
    RUN if [ -z "${USER_PASSWD}" ] ; then \
            echo USER_PASSWD is a mandatory build argument && exit 1 ; \
        fi
    RUN useradd -m -d /var/home/redhat -G wheel redhat && \
        echo "redhat:${USER_PASSWD}" | chpasswd
    
    # Mandatory firewall configuration
    RUN firewall-offline-cmd --zone=public --add-port=22/tcp && \
        firewall-offline-cmd --zone=trusted --add-source=10.42.0.0/16 && \
        firewall-offline-cmd --zone=trusted --add-source=169.254.169.1
    
    # Create a systemd unit to recursively make the root filesystem subtree
    # shared as required by OVN images
    RUN cat > /etc/systemd/system/microshift-make-rshared.service <<'EOF'
    [Unit]
    Description=Make root filesystem shared
    Before=microshift.service
    ConditionVirtualization=container
    [Service]
    Type=oneshot
    ExecStart=/usr/bin/mount --make-rshared /
    [Install]
    WantedBy=multi-user.target
    EOF
    RUN systemctl enable microshift-make-rshared.service

    重要

    Podman uses the host subscription information and repositories inside the container when building the container image. If the rhocp and fast-datapath repositories are not available on the host, the build fails.

  2. Create a local bootc image by running the following image build command:

    PULL_SECRET=~/.pull-secret.json
    USER_PASSWD=<your_redhat_user_password> 
    1
    
    IMAGE_NAME=microshift-4.17-bootc
    
    $ sudo podman build --authfile "${PULL_SECRET}" -t "${IMAGE_NAME}" \
        --build-arg USER_PASSWD="${USER_PASSWD}" \
        -f Containerfile
    1
    Replace <your_redhat_user_password> with your password.
    注記

    How secrets are used during the image build:

    • The podman --authfile argument is required to pull the base rhel-bootc:9.4 image from the registry.redhat.io registry.
    • The build USER_PASSWD argument is used to set a password for the redhat user.

Verification

  1. Verify that the local bootc image was created by running the following command:

    $ sudo podman images "${IMAGE_NAME}"

    Example output

    REPOSITORY                       TAG         IMAGE ID      CREATED        SIZE
    localhost/microshift-4.17-bootc  latest      193425283c00  2 minutes ago  2.31 GB

Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

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

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

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

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

Legal Notice

Theme

© 2026 Red Hat
トップに戻る