Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Creating a VMDK using image mode for Red Hat Enterprise Linux

July 15, 2024
Andrew Block
Related topics:
Developer ProductivityHybrid CloudIntegrationLinuxApplication modernizationVirtualization
Related products:
Image mode for Red Hat Enterprise LinuxRed Hat Enterprise Linux

Share:

    Image mode for Red Hat Enterprise Linux (RHEL) combines the benefits and methodologies of container technologies with the ability to operate within traditional virtual machine environments. By enabling a familiar container image assembly process that supports several popular output types, end users have the flexibility to choose where and how they want to operate.

    One of the supported output formats is a Virtual Machine Disk (VMDK), which is commonly used within VMware’s supported virtualization platforms, like vSphere, but support is also available elsewhere, including VirtualBox. Bridging the gap between traditional operating environments and cloud-native technologies is one of the benefits that image mode provides. 

    Over the course of this series, we will describe the process for creating image mode for RHEL-based bootc images for use within VMware environments, that, when included within reusable templates, will enable a consistent method for delivering virtual environments. Plus, several different methods will also be provided that illustrate how the generation of the various assets can be automated to create a repeatable factory for delivering bootc images to meet the demands of today and tomorrow.

    Read more about image mode for RHEL.

    Creating a RHEL bootc image

    While there is a lot of ground that will be covered throughout this series, this article will focus specifically on the creation of a bootc image that both provides the necessary primitives needed to operate within the desired target environment, and can either be used as-is, or act as the baseline for an entire lineage of downstream content. Once this bootc image has been created, we will then showcase how a VMDK disk can be created.

    Producing a bootc image is no different than developing a standard container image. A Dockerfile or Containerfile describes the composition -- from the base image providing the foundation for the desired components that should be included, such as system packages, applications, and configurations.

    Start off by creating a new directory called rhel-bootc-vmdk and underneath the newly created directory, create two folders: image and output, and change into the rhel-bootc-vmdk directory.

    mkdir -p rhel-bootc-vmdk/{image,output}
    cd rhel-bootc-vmdk

    Create a new file within the image directory called Containerfile (image/Containerfile) with the following content:

    FROM registry.redhat.io/rhel9/rhel-bootc:9.4
    RUN dnf -y install cloud-init open-vm-tools && \
        ln -s ../cloud-init.target /usr/lib/systemd/system/default.target.wants && \
        rm -rf /var/{cache,log} /var/lib/{dnf,rhsm} && \
        systemctl enable vmtoolsd.service

    While somewhat simple in nature, this RHEL 9 bootc image includes several additional RPM packages that provide flexibility to operate as virtual machines within the target environment. We will cover the significance of these packages in a subsequent article.

    Prior to creating a bootc image, ensure that your local machine has completed the following steps:

    • Installed a container runtime
    • Authenticated to the Red Hat Registry.

    If not, use the steps below:

    1. Install Podman
    dnf install -y podman
    1. Authenticate to the Red Hat Registry
    podman login registry.redhat.io

    Enter your Red Hat credentials when prompted for your username and password.

    With the necessary prerequisites complete, create a new Image Mode for RHEL image with the tag localhost/rhel-bootc-vmdk with the Containerfile created previously:

    podman build -f image/Containerfile -t localhost/rhel-bootc-vmdk image

    Once the build process has finished, feel free to explore the contents of the produced image by using the podman run command. The options available for running a bootc  image locally can be found within the documentation. 

    Now that the desired image has been created, let’s shift our attention to what it takes to produce a VMDK disk file.

    Producing a VMDK disk

    A VMDK disk is just one of the supported output types that image mode for RHEL supports. Other formats include ISO, QCOW2, AMI, and VMI. Disk images can be deployed within a variety of environments, such as various public and private cloud platforms and edge servers which exemplifies the versatility that image mode for RHEL provides.

    Disk images based on bootc images are produced using the bootc-image-builder containerized build tool. Similar to the base rhel-bootc image, it is also available from the Red Hat Registry for use on your local machine.

    Execute the following command to retrieve the image:

    podman pull registry.redhat.io/rhel9/bootc-image-builder:9.4 

    Once the image has been retrieved, the set of options that can be used to tailor the disk creation process can be found by running the image and exploring the choices available from the embedded bootc-image-builder CLI:

    podman run -it --rm registry.redhat.io/rhel9/bootc-image-builder:9.4 --help

    Options, such as the type of disk format can be specified using the --type argument, and the destination of the resulting disk image using the --output argument. Additional options are also available for specific types of output formats. In particular, the AMI format supports automating the upload of the resulting AMI image to Amazon Web Services (AWS). 

    Generate a VMDK file from the previously created bootc image and target the output directory to store the produced disk image.

    sudo podman run --rm -it --privileged -v /var/lib/containers/storage:/var/lib/containers/storage -v ./output:/output --security-opt label=type:unconfined_t --pull newer registry.redhat.io/rhel9/bootc-image-builder:9.4 --local --type vmdk localhost/rhel-bootc-vmdk:latest

    Notice the use of the --local argument within the command above. This option will leverage the local container storage to source the originating image to produce the VMDK instead of a remote repository. In most cases, you will want to publish a bootc image so that it can be consumed by others. However, in this case, since there was no requirement that the produced image was needed by another individual, this step was not necessary.

    Once complete, a VMDK disk file for the bootc image is stored in the output/vmdk directory, which is then usable on platforms supporting the VMDK file type. Keep in mind that additional output formats can be specified from the same bootc image enabling a single source of truth that can be deployed to a variety of environments and platforms. 

    Summary

    In this article, we described how to use the rhel-bootc base image to create bootc image and then take the resulting image and produce a VMDK file using the bootc-image-builder utility. With a VMDK file now available, we have the base primitives to support our overarching goal of using it at scale within a VMware vSphere environment. In the next article, we will discuss the steps to take the VMDK file, load it within a vSphere environment, and use it in a virtual machine.

    In the next post in this series, we will describe how the previously created VMDK disk can be used as the basis for a virtual machine hosted in a VMware vSphere environment.

    Last updated: August 5, 2024

    Recent Posts

    • AI meets containers: My first step into Podman AI Lab

    • Live migrating VMs with OpenShift Virtualization

    • Storage considerations for OpenShift Virtualization

    • Upgrade from OpenShift Service Mesh 2.6 to 3.0 with Kiali

    • EE Builder with Ansible Automation Platform on OpenShift

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    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
    © 2025 Red Hat

    Red Hat legal and privacy links

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

    Report a website issue