Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

How to build an image mode pipeline with GitLab

Automated OS deployment

February 12, 2026
Preethi Thomas Chris Kyrouac
Related topics:
Automation and managementCI/CDContainersLinux
Related products:
Image mode for Red Hat Enterprise LinuxRed Hat Enterprise Linux

    This guide provides a step-by-step process for creating a robust, automated CI/CD pipeline for image mode for Red Hat Enterprise Linux (RHEL) using GitLab. Image mode, utilizing the power of bootc (bootable containers), fundamentally shifts how we manage and deploy operating systems. Instead of traditional package management, we treat the OS as a container image, making deployments immutable, verifiable, and highly consistent.

    Set up the pipeline

    Before setting up the pipeline, ensure you have the following prerequisites:

    1. GitLab project: You must have a repository containing your image mode configuration. For the purpose of this example, include a Containerfile and an example systemd service. This is the layout of the project:
    ├── Containerfile
    └── etc
        └── systemd
            └── system
                └── my-app.service
    1. my-app.service: This is a simple custom systemd service.
    [Unit]
    Description=My app
    [Service]
    Type=oneshot
    ExecStart=/usr/sbin/echo "My app"
    [Install]
    WantedBy=default.target
    1. Containerfile: This file defines your image mode base image and any custom packages or configurations.
    # Example starting point (adjust version as necessary)
    FROM registry.redhat.io/rhel10/rhel-bootc@sha256:3cf9522137f3b643a780d303ee6a823cc04df847c24a4103d5563cd44785df04
    # Copy the systemd service into the bootc image
    COPY etc etc
    # Install custom packages
    RUN <<EOF
        set -euxo pipefail
        dnf install -y cockpit-ws httpd
        dnf clean all
    EOF
    1. GitLab variables: Securely store your Red Hat container registry credentials (e.g., CI_REGISTRY_USER, CI_REGISTRY_PASSWORD) and subscription secrets (RH_USER, RH_PASSWORD) as GitLab CI/CD variables.

    The image mode CI/CD pipeline flow process involves three primary stages: build, package, and deploy.

    Stage 1: Dependency management

    While not strictly a CI job, automatic dependency management is crucial for maintaining an up-to-date and secure base OS image. The goal is to use a dependency bot (i.e., Renovate Bot or Dependabot) to automatically detect new versions of the parent image (registry.redhat.io/rhel10/rhel-bootc:10.1).

    The key concept is to guarantee reproducible builds and enhanced security. You should reference your parent image using both a static tag and its content digest (SHA256). The bot will automatically update the digest in a merge request when the underlying image content changes.

    Stage 2: Building and pushing the bootc container image

    This is the first true CI stage, where the Containerfile is executed to produce the final, bootable container image. Use this container image to create the installation disk and to upgrade existing systems. Create .gitlab-ci.yml in the root of your project with the following contents.

    Tools: Podman or Buildah are ideal for this stage. They are often available in standard GitLab runners, or you can run them within a specialized runner image.

    GitLab CI job (.gitlab-ci.yml):

    stages:
      - build
      - package
      - deploy
    # Use semantic versioning for release tags (e.g., 1.0.0)
    variables:
      IMAGE_NAME: $CI_REGISTRY_IMAGE/my-rhel-os
      IMAGE_TAG: $CI_COMMIT_SHORT_SHA
    build_bootc_image:
      stage: build
      image: registry.access.redhat.com/ubi10/podman:latest
      script:
        - |
          set -euxo pipefail
          # Login to the gitlab registry where this image will be pushed to
          podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
          # Login to registry.redhat.com so we can pull the rhel-bootc image
          podman login -u $RH_REGISTRY_USER -p $RH_REGISTRY_PASSWORD registry.redhat.io
          subscription-manager register --username $RHN_USER --password $RHN_PASSWORD
          # Set up entitlement secrets for podman build
          # Podman expects these at /run/secrets/ per /etc/containers/mounts.conf
          # This is a hack to enable rhsm for demonstration purposes
          # In a production environment the runner should be registered with RHSM.
          mkdir -p /run/secrets/etc-pki-entitlement
          cp /etc/pki/entitlement/*.pem /run/secrets/etc-pki-entitlement/
          mkdir -p /run/secrets/rhsm
          cp -r /etc/rhsm/* /run/secrets/rhsm/
          podman build -t $IMAGE_NAME:$IMAGE_TAG .
          podman push $IMAGE_NAME:$IMAGE_TAG

    Stage 3: Packaging the disk image (OS artifact)

    The bootc image is not directly deployable to bare metal or VMs. You must convert it into a disk image format (e.g., .qcow2, .ami, .vmdk). This is where the bootc-image-builder (BIB) tool comes in. Update .gitlab-ci.yml with a new build_disk_image job.

    Tools: Run the bootc-image-builder as a container, making it easy to integrate.

    GitLab CI job (.gitlab-ci.yml):

    # Convert the bootc image to a disk image (qcow2 example)
    build_disk_image:
      stage: package
      tags:
        - saas-linux-large-amd64
      image:
        name: quay.io/centos-bootc/bootc-image-builder:latest
        entrypoint: [""]
      needs:
        - build_bootc_image
      script:
        - |
          set -euxo pipefail
          mkdir output
          podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
          podman pull $IMAGE_NAME:$IMAGE_TAG
          bootc-image-builder $IMAGE_NAME:$IMAGE_TAG --type qcow2 --output ./output
      artifacts:
        paths:
          - output/*.qcow2

    Note: The bootc-image-builder requires --privileged mode to handle the necessary disk partitioning and filesystem creation, so your runner must support this. The shared instance runners on Gitlab are not supported, so you will need a custom runner for this step.

    Stage 4: Deployment and storage

    The final stage pushes the compiled OS artifact (.qcow2 file) to an accessible location, typically an object storage service like Amazon S3, Azure Blob Storage, or a private server.

    Tools: Use cloud provider CLIs (e.g., AWS or AZ) or standard Linux tools (curl, rsync) depending on your target.

    GitLab CI job (.gitlab-ci.yml):

    # Upload the disk image to object storage for deployment
    deploy_image_artifact:
      stage: deploy
      image: python:latest # Use a common image that can install cloud CLIs
      needs:
        - build_disk_image
      script:
        - echo "--- Installing AWS CLI (Example) ---"
        - pip install awscli
        # Ensure AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set as CI variables
        
        - echo "--- Uploading qcow2 file to S3 ---"
        - FILE_PATH=$(find output -name "*.qcow2")
        - aws s3 cp $FILE_PATH s3://your-os-artifacts-bucket/rhel-image-mode/$IMAGE_TAG.qcow2
        
        - echo "Deployment artifact available at: s3://your-os-artifacts-bucket/rhel-image-mode/$IMAGE_TAG.qcow2"
      # Only run this job when pushing to the main branch
      only:
        - main 

    Wrap up

    By structuring your GitLab CI/CD pipeline around the three stages—building the bootc container, packaging the disk image using bootc-image-builder, and deploying the artifact—you can fully automate your image mode operating system updates. You can easily provision new systems with the disk image and update existing systems with the new container image. This approach guarantees consistency, leverages container security features, and dramatically speeds up your OS deployment and patching cycles.

    Related Posts

    • Image mode for RHEL 10: Updates in seconds with soft reboot

    • Customize RHEL CoreOS at scale: On-cluster image mode in OpenShift

    • How to deploy an image mode update in offline and air-gapped environments

    • How to embed containers on image mode for RHEL

    Recent Posts

    • Protect data offloaded to GPU-accelerated environments with OpenShift sandboxed containers

    • Case study: Measuring energy efficiency on the x64 platform

    • How to prevent AI inference stack silent failures

    • Preventing GPU waste: A guide to JIT checkpointing with Kubeflow Trainer on OpenShift AI

    • How to manage TLS certificates used by OpenShift GitOps operator

    What’s up next?

    Learning Path Install_image_mode_for RHEL_kickstart feature image

    Install image mode for Red Hat Enterprise Linux using Kickstart

    Deploy image mode for Red Hat Enterprise Linux step-by-step using Kickstart,...
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.