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

Using containerization for modern hybrid cloud application development

Developer for the modern hybrid cloud using containers

January 8, 2024
Yashwanth Maheshwaram
Related topics:
Application modernization
Related products:
Podman DesktopRed Hat Enterprise LinuxRed Hat OpenShift

Share:

    Installing components directly on a server or in a virtual machine’s (VM) operating system demands significant updates and maintenance to ensure compatibility. In contrast, a containerized service and its dependencies run as a self-contained unit. You can deploy these containers into a managed cloud system to concentrate on the service instead of maintaining an operating system.

    Well-defined image files let modern applications scale in response to demand. Run Pods in a cloud environment when local servers are near capacity, or balance a workload across multiple regions or cloud providers for resilience. It doesn’t matter where each container runs as long as it can access resources.

    Encapsulation ensures a high degree of consistency and reproducibility, facilitating debugging and troubleshooting. To revert to the service’s previous version, simply make containers from a good image.

    Breaking monolithic services into containerized microservices minimizes the attack surface, too, particularly compared to VMs. Containers offer significant tenancy advantages over VMs due to their architecture. While VMs require separate copies of an entire operating system, containers share underlying layers of file differences, allowing multiple containers to use the same file space, thereby significantly increasing density and efficiency. Also, with containerization, you can identify security-affected image versions and then create and deploy new patched images.

    A previous article illustrated dividing a monolithic Java application (an e-commerce bicycle app called Pedal) into various microservices. This article demonstrates how to containerize those microservices and host the images for swift deployment and scalability as your application expands.

    Essentials of containerization

    RHEL

    Red Hat® Enterprise Linux® (RHEL) is a Linux distribution for enterprises valuing stability, robustness, and professional support. Typically installed on a server, RHEL comes with training, certification, and tooling.

    Red Hat Enterprise Linux CoreOS (RHCOS), a variant integrated into the Red Hat OpenShift Container Platform, is explicitly optimized for containerized environments, allowing centralized upgrades.

    Podman

    Pods are container groups sharing resources and running together.

    Red Hat engineers developed Podman, an open source command-line tool for managing images and containers, and its graphical user interface (GUI) equivalent, Podman Desktop. Podman is similar to Docker but doesn’t need a daemon service, making it more secure and accessible.



     

    Quay

    Red Hat® OpenShift® includes an integrated registry with pre-configured Red Hat Universal Base Images (UBIs), including certified container images.

    Red Hat OpenShift Platform Plus includes Red Hat Quay. It’s a private image registry that lets you create multiple image repositories while controlling their push and pull permissions. Red Hat Quay’s resilience, scalability, and security focus make it a suitable choice for multiple clusters or single-point security.

     

    OpenShift

    Red Hat OpenShift is the Kubernetes orchestration tool’s enterprise version.

    In this tutorial, you’ll use the Developer Sandbox for Red Hat® OpenShift® (and the OpenShift CLI) to containerize your microservices and host your images. The Developer Sandbox helps you explore Red Hat’s practical and time-saving developer tools tailored for containerization and more.



     

    Containerization and cloud-native journey

    Setting up Podman Desktop

    First, install Podman Desktop from the Developer Sandbox and set it up.

    Podman Desktop dashboard.

    Setting up the example application

    Now, you’ll deploy the Pedal sample application to the Developer Sandbox for Red Hat OpenShift to containerize the Bike Service.

    First, clone the Red Hat Pedal repository from GitHub to edit it locally using the following command:

    git clone https://github.com/redhat-developer-demos/pedal-user-service

     

    Then, append the following line to the src/main/resources/application.properties file:

    spring.thymeleaf.prefix=/WEB-INF/classes/templates/

    Next, edit the pom.xml file as follows:

    <properties>
        <java.version>17</java.version>
    </properties>
    
    
    
    The file should now look like this:
    
    <description>Bike commerce application</description>
    <packaging>war</packaging>
    <properties>
        <java.version>17</java.version>
        <start-class>com.redhat.Bike.Service</start-class>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

     

    Add the following code just before the end of the plugins section in pom.xml:        

           <plugin>
                 <artifactId>maven-war-plugin</artifactId>
    
                 <configuration>
    
                     <attachClasses>true</attachClasses>
    
                     <webResources>
    
                         <resource>
    
                             <directory>src/main/resources</directory>
    
                             <filtering>true</filtering>
    
                         </resource>
    
                     </webResources>
    
                 </configuration>
    
             </plugin>

    In the cloned repository’s top level, create a ContainerFile file with the following contents:

    FROM maven AS build
    
    COPY src /home/default/src
    
    COPY pom.xml /home/default/
    
    WORKDIR /home/default/
    
    RUN mvn install -Dmaven.test.skip
    
    FROM registry.access.redhat.com/ubi9/openjdk-17-runtime
    
    RUN mkdir -p /home/default/target
    
    COPY --from=build /home/default/target/bike_commerce-0.0.1-SNAPSHOT.war /home/default/target/bike_commerce-0.0.1-SNAPSHOT.war
    
    # CMD java -jar /home/default/target/bike_commerce-0.0.1-SNAPSHOT.war
    
    CMD while true; do echo "heartbeat"; sleep 10; done

    The code’s while true loop is a simple way to keep the container active and operational. Otherwise, the container stops functioning after running these commands. This approach is beneficial in environments where a container needs to continue running, even if the primary application isn't active or is being debugged. Additionally, the ContainerFile text above uses Red Hat UBI, which uses RHEL, letting you build an image that runs on RHEL.

    Next, in Podman Desktop, navigate to the Images section and click Build an image.

    In the Containerfile path, select the new ContainerFile. In Image Name, type pedal. Set Container Engine to Podman and click Build:

    Podman Desktop Build Image from Containerfile page with fields for path, build context directory, image name, and container engine, plus a build button.

    You should get a notification message about the successful build. Click Done to go back to the Images list.

    Next, click Run image next to your new image, then click Start Container.

    Podman Desktop Create a container page with fields for container name, entrypoint, command, volumes, and port mapping, plus a Start Container button.

    You should now see a list of running containers, including your new one. Click it to view its logs. To stop the container, click the stop symbol.

    Journey to OpenShift

    In Podman Desktop, navigate to the dashboard (the top menu item) and install the Developer Sandbox extension.

    Note that the Red Hat OpenShift Developer Sandbox offers a unique default behavior compared to standard OpenShift production environments, particularly for registry access. In the Developer Sandbox, the registry address is exposed by default, letting you directly import images into your project namespace. This approach contrasts with the default behavior in a typical OpenShift production environment, where access to the registry is more restricted and isolated to enhance security and control in enterprise settings. This difference highlights the Developer Sandbox's focus on enabling ease of use and experimentation for developers instead of prioritizing security and controlled access for production environments.

    Extension options on the Podman Desktop dashboard.

    Navigate to Settings, then Resources in Podman Desktop. Click Create new… to configure access to your existing Developer Sandbox:

    Developer Sandbox page with a Create new button.

    Follow the on-screen instructions log in and obtain a login link. Paste the link in the Login command from Developer Console field. Click Create:

    Podman Desktop Create a Developer Sandbox page with a name, Set as current context disabled, and a login command from Developer Console.

    You should get a message confirming the operation was successful.

    Now, right-click the Podman Desktop tray icon, select Kubernetes, and ensure you checkmark your sandbox context. If you don’t have the Kubernetes option yet, try closing and restarting Podman Desktop:

    Menu with the sandbox context checkmarked.

    Switch to the Images tab and click the three vertical dots beside your custom image. Because you installed the Developer Sandbox extension, a menu option appears: Push image to Developer Sandbox cluster. Select it:

    Images tab with menu options.

    This action retags the image, creating a new entry in the image list. The image push may take a minute or two, depending on your network connection speed. Wait for a message confirming a successful push. Click OK. 

    Note: As mentioned above, the registry address in the Red Hat OpenShift Developer Sandbox is exposed by default, helping you effortlessly push images directly into your project namespaces. However, in a standard OpenShift cluster, the integrated registry isn’t exposed as a route by default. Exposing it requires additional configuration to set up the route, reflecting a more cautious approach to security and access control in production environments.

    Message saying the image was successfully pushed to the cluster.

    Run the newly tagged image to create a container, as you did with the original image. You’ll see a list of containers with the new container running.

    Click the container. Then, press the rocket ship icon in the top right to deploy the container to Kubernetes:

    Menu items including a rocketship icon.

    Leave the default options unchanged and click Deploy. Once complete, hit Done. Click the Pods section in Podman Desktop to view your pod running on your Developer Sandbox cloud:

    Podman Desktop Pods page showing the Pod running.

    You can also use your browser to view the pod running in the Developer Sandbox. Just set the user to Administrator and navigate to Workload / Pods in the menu:

    Red Hat OpenShift Pods page with the Pod's status as "running."

    Note: The Pedal microservices require a PostgreSQL Database function. To run these services, use the PostgreSQL ContainerFile and the init.sql script to create a containerized database. Alter the service properties file to point to it.

    Hosting images on an image registry

    Pushing an image to Quay from Podman Desktop is straightforward. Sign in to Red Hat Quay with your Red Hat login, then click Create New Repository on the home screen:

    Red Hat Quay home screen.

    Name the repository as desired. In Podman Desktop, click the image and click Push. Enter the repository’s details and click Push. Your image is now accessible from anywhere using Quay.

    You can also use Podman CLI instead of Podman Desktop to push and pull images.

    Next steps

    You’ve learned how to use Podman and Red Hat Quay to build images and containers locally and then push them to Red Hat OpenShift. These Red Hat tools streamline the creation, deployment, security, and management of containers — a core component of modern software system design. Your DevOps team can deploy new features and fixes faster, freeing time for more innovation and collaboration across different environments.

    Learn more about containerization in hybrid cloud application development:

    • Deploy a container on the Developer Sandbox for Red Hat OpenShift.
    • Use Red Hat Enterprise Linux (RHEL).
    • Explore Podman Desktop.
    Last updated: April 29, 2024

    Recent Posts

    • 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

    • How to debug confidential containers securely

    • Announcing self-service access to Red Hat Enterprise Linux for Business Developers

    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