9장. 처음부터 bootc 이미지 생성


기존 bootc 기본 이미지를 입력하는 RPM 패키지를 사용하여 빌드 환경으로 사용하여 처음부터 bootc 이미지를 생성할 수 있습니다. 이를 통해 기본 이미지 콘텐츠를 제어할 수 있으며 워크로드에 필요한 패키지만 포함하여 시스템 공간 사용량 및 공격 면적을 줄일 수 있습니다.

9.1. 고정된 콘텐츠를 사용하여 이미지 빌드

재현 가능한 빌드를 유지하려면 리포지토리 스냅샷 툴을 사용하여 기본 이미지를 특정 패키지 버전에 고정할 수 있습니다. 이렇게 하면 rpm-md 또는 yum 리포지토리가 프로젝트의 lockfiles와 일관되게 유지됩니다.

bootc image from scratch 사용하면 미러링된, 고정 또는 스냅샷된 리포지토리 콘텐츠를 참조하는 동안 소스 RPM 리포지토리에서 패키지 정보를 구성하고 재정의할 수 있습니다. 결과적으로 패키지 버전과 해당 종속성을 제어할 수 있습니다.

사전 요구 사항

  • 표준 부팅 기본 이미지입니다.

절차

  • 다음 예제에서는 고정된 콘텐츠를 사용하여 처음부터 부팅 이미지를 생성합니다.

    # Begin with a standard bootc base image that serves as a "builder" for our custom image.
    FROM registry.redhat.io/rhel10/rhel-bootc:latest as builder
    # Configure and override source RPM repositories, if necessary. The following step is required when referencing specific content views or target mirrored/snapshotted/pinned versions of content.
    RUN rm -rvf /etc/yum.repos.d; mkdir -p /etc/yum.repos.d/
    COPY mypinnedcontent.repo /etc/yum.repos.d/
    # The file must be copied to the /etc/yum.repos.d/ directory.
    # The mypinnedcontent.repo is your standard repository that ensures that your container will always be built with the exact same versions of software, preventing unexpected bugs or security issues from new updates.
    # Build the root file system using the specified repositories and non-RPM content from the "builder" base image.
    # If no repositories are defined, the default build will be used. You can modify the scope of packages in the base image by changing the manifest between the "standard" and "minimal" sets.
    # Add additional repositories to apply customizations to the image. However, referencing a custom manifest in this step is not currently supported without forking the code.
    RUN /usr/libexec/bootc-base-imagectl build-rootfs --manifest=standard /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/ /
    # Apply customizations to the image. This syntax uses "heredocs" https://www.docker.com/blog/introduction-to-heredocs-in-dockerfiles/ to pass multi-line arguments in a more readable format.
    RUN <<EORUN
    # Set pipefail to display failures within the heredoc and avoid false-positive successful builds.
    set -xeuo pipefail
    # Install necessary packages, run scripts, etc.
    dnf -y install NetworkManager emacs
    # Remove leftover build artifacts from installing packages in the final built image.
    dnf clean all
    rm /var/{log,cache,lib}/* -rf
    EORUN
    # Define required labels for this bootc image to be recognized as such.
    LABEL containers.bootc 1
    LABEL ostree.bootable 1
    # Optional labels that only apply when running this image as a container. These keep the default entry point running under systemd.
    STOPSIGNAL SIGRTMIN+3
    CMD ["/sbin/init"]
    # Run the bootc linter to avoid encountering certain bugs and maintain content quality. Place this command last in your Containerfile.
    RUN bootc container lint

검증

  1. 이미지를 저장하고 빌드합니다.

    $ podman build -t quay.io/<namespace>/<image>:<tag> . --cap-add=all --security-opt=label=type:container_runtime_t --device /dev/fuse
  2. 현재 디렉터리의 Containerfile 을 사용하여 <_image_> 이미지를 빌드합니다.

    $ podman build -t quay.io/<namespace>/<image>:<tag> .
Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 문서 정보

Legal Notice

Theme

© 2026 Red Hat
맨 위로 이동