8.2. 최소에서 기본 이미지 빌드


고급 이미지 사용자 지정을 위해 표준 기본 운영 체제 이미지에서 파생된 최소 bootc 이미지를 생성할 수 있습니다. 이 경량 이미지에는 bootc 툴, 커널 및 DNF 패키지 관리자만 포함됩니다.

최소 bootc 이미지는 후속 다중 단계 빌드의 기본 계층 역할을 수행하도록 설계되었습니다. 최종 이미지 콘텐츠를 제어할 수 있습니다.

참고

이 최소 이미지는 현재 레지스트리에 사전 빌드되지 않으며 로컬로 생성해야 합니다.

사전 요구 사항

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

프로세스

  • 다음 예제에서는 사용자 정의 최소 기본 이미지를 생성합니다.

    # Begin with a standard bootc base image that is reused as a "builder" for the custom image.
    FROM registry.redhat.io/rhel10/rhel-bootc:latest as builder
    # Configure and override source RPM repositories, if necessary. This step is not required when building up from minimal unless referencing specific content views or target mirrored/snapshotted/pinned versions of content.
    # 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.
    # Build the root file system by 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.
    RUN /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/ /
    # 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 required packages for our custom bootc image.
    # Note that using a minimal manifest means we need to add critical components specific to our use case and environment.
    dnf -y install NetworkManager openssh-server
    # Remove package caches
    dnf clean all
    # Clean up all logs and caches
    rm /var/{log,cache,lib}/* -rf
    # Run the bootc linter to perform build-time verification. Keep this as the last command in your build instructions.
    bootc container lint
    # Close the shell command.
    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"]
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 소개

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

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

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

Red Hat 문서 정보

Legal Notice

Theme

© 2026 Red Hat
맨 위로 이동