Page
Build and run a bootable Django application disk image in Podman Desktop

Now that you’ve accessed the container registry and have your configuration files, it’s time to create a disk image and set up a virtual machine.
Prerequisites:
- A no-cost Red Hat Developer subscription.
- Register here if you do not have a subscription.
- Podman Desktop.
- You can download Podman Desktop for Windows, macOS, or Linux.
- The configuration files in the d
jango-dev/bootc
directory from the previous lesson:django.service
nginx-myproject.conf
containerfile
- Your development files from Lesson 2, which are in the
django-dev/bootc/app
directory.
In this lesson, you will:
- Create your first disk image.
- Build an image from the
containerfile
. - Build a disk image.
- Set up a virtual machine (VM).
Create your first disk image
In Lesson 1, we installed the Red Hat Extension Pack, which includes the Bootable Containers extension used for image mode deployments. To pull your first bootable container, follow these steps:
In Podman Desktop, select Bootable Containers from the side menu bar to access the Dashboard section (Figure 1).
Figure 1: Welcome to Bootable Containers dashboard screen. - Within the Bootable Containers section, select Images from the left navigation.
On the Images screen, select the option to pull the example container image from registry.gitlab.com (Figure 2).
Figure 2: Bootable containers images listing screen with the example image now available. - Once you complete this, you will see the example image.
Note
The file size of the image is over 700MB (compressed) and may take a while to download.
Build an image from the containerfile
Next, let’s use the Containerfile we created in Lesson 3 to build an image:
- Open Podman Desktop on your local machine and go to the Images section in the left navigation.
- Select Build to open the Build image from the Containerfile screen.
- Provide the following:
- Containerfile path: your_home_directory/django-dev/bootc/containerfile,
- Build directory path: your_home_directory/django-dev/bootc
- Image name: django-bootc-image
Platform hardware spec: I chose the Intel and AMD x86_64 image option for my desktop environment (Figure 3).
Figure 3: The Build image from Containerfile screen in Podman Desktop.
Select Build once you have all of the information entered. Observe if any issues or warnings are displayed while building the image. Once you’ve successfully created the image (Figure 4), it will be listed on the Images dashboard (Figure 5).
Figure 4: Successful Containerfile build output in Podman Desktop. Figure 5: The container images listing screen with a new entry for the example image.
At this point, our image can run like any other container with Podman. This can be highly beneficial for basic testing and iterating on your application. In the next step, you will install (write) your container image as a disk image and run it as a Linux system.
Build a disk image
While a traditional application container image is like a self-contained software package that you install onto an existing OS, image mode uses bootc
to deliver a complete, bootable OS installation disk, but managed and versioned like a container image. The magic of bootc
is that it can install the contents of the container image to disk or file system and provide any format you need to run on virtually any platform. Podman Desktop makes this process simple, and you can target a wide variety of platforms and image types.
To build an image in Podman Desktop:
- Open Podman Desktop on your local machine and go to the Images section from the left navigation. If you just completed the prior steps, you will already be on this screen.
Select the option to Build Disk Image from the ACTIONS kebab (Figure 6).
Figure 6: The Podman Desktop container images screen with the expanded menu under the actions kebab. - Select Build on the Disk Images.
Provide the configuration details. For the purposes of this exercise, we chose Virtualization Guest Image (qcow2) as the image type and a default filesystem (Figure 7).
Figure 7: The completed Build Disk Image configuration. Expand the Interactive build config section towards the bottom of the screen. This is where you will enter your SSH credentials you will need for the next section (Figure 8).
Figure 8: The expanded interactive build config section for building a disk image in Podman Desktop. - Select Build.
Observe if any issues or warnings are displayed while building the disk image. Once you’ve successfully created the image, you will see a success message (Figure 9) listed in the Bootable Containers > Disk Images section of Podman Desktop.
Figure 9: A successful disk image build.
Set up a virtual machine
Virtual environments provide a quick and convenient way to test your images. You can test modifications and configurations without impacting your primary operating system or incurring cloud expenditures. Once your image has been validated and you’re happy with it, we encourage you to create images for all the platforms you’d like to target.
Podman Desktop version 1.8.0 and later makes it easy to launch your built disk image as a virtual machine. After successfully building your disk image, simply select Virtual Machine (Experimental). Before doing so, please ensure you've met the necessary prerequisites, which may include specific hardware or software requirements.
Summary
This learning path demonstrates how easy it is to add the Red Hat SSO extension to Podman Desktop and access the Red Hat registry to create a Django-based application container image that is ready to boot and run with image mode. You can easily extend the rudimentary bootable Django application container you created into a functional application.
As a developer, there are several reasons why you should care about deploying the application in image mode:
- Full-stack reproducibility: Image mode allows you to define your app, user space, and the entire OS, ensuring consistency from development to production.
- Simplified OS management: You can now treat OS updates and configurations as image rebuilds, integrating them into your existing container workflows.
- Ideal for appliances and edge: Image mode is perfect for creating specialized software appliances or consistent OS environments for edge devices with tightly coupled OS and applications.
- Testing: With image mode, it is easy to spin up VMs on your desktop or in the cloud, running the exact OS and application build for testing.
The next steps you could take in completing your application might include the following:
- Extending the application code beyond the prototype "Hello World."
- Integrating the application with a database, such as SQLLite, MariaDB, MySQL, and PostgreSQL.
- Configuring keys and infrastructure to improve the security of the NGINX server component.
Want to learn more? Check out: