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

Container Images for OpenShift – Part 3: Making your images consumable

 

October 16, 2017
Frédéric Giloux
Related topics:
ContainersKubernetes
Related products:
Red Hat OpenShift Container Platform

Share:

    This is a transcript of a session I gave at EMEA Red Hat Tech Exchange 2017, a gathering of all Red Hat solution architects and consultants across EMEA. It is about considerations and good practices when creating images that will run on OpenShift. This third part focuses on how you can make your images easier to consume by application developers or release managers.

    Versioning

    When you specify an image for starting containers or creating child images you need to provide the version you want to use. If you don't the version with the "latest" tag is used.

    Let's have a look at the way Red Hat creates a version hierarchy. This is a good example of a strategy that you could reuse for your own images.

    A very important aspect is maintaining backward compatibility within a tag for downstream consumers. The publication of a new version of the image should not break the child images.

    Red Hat image versions are aligned with the product, which is part of the container. Here is, for instance, the way rhel7/rhel is tagged:

    7.4-81 / 7.4 / latest
    7.3-97 / 7.3
    7.3-95
    7.3-82
    ...

    Note that there isn't a 7 tag, as compatibility is not guaranteed between major releases only between minor releases. See the bottom of this article. The tags 7.4-81, 7.4 and the latest reference the same image. The image consumer is free to point to one of these tags with the consequence:

    • latest: The consumer gets a different image every time a new version is pushed.
    • 7.4: The consumer gets a different image every time a new version of the minor release 7.4 is pushed. Child images get patches automatically.
    • 7.4-81: The consumer does not get updates.

    For anything that you aim to validate and run in production, you should target a stable tag and not use the latest. The recommendation is to point to the minor release: 7.4 in the example so that your image is automatically updated with patches. If you go for a specific release: 7.4-81 you will need to have a suitable workflow in place for patching your own images.

    You may use the latest tag inside the project where the image is developed for seeing the latest changes automatically. More rarely, you may want, during your development phase, to be on the latest version, whenever it is made available, of an image you consume.

    Documentation

    The next aspect in making your image consumable is obviously documentation. A user guide is certainly something useful but there are also things you can do to the image or OpenShift level.

    Providing a template with a quick start shows how users can run applications based on your image.

    Using the image metadata, you can have the most important points documented with the image itself:

    • You can use labels to add a description, to provide contact information of the maintainer, the address of the authoritative source, build, release and component information, etc.
    • Exposing important ports in the Dockerfile gives also important information on how the image should be run and your application connected to.
    • Same with exposing volumes. The image consumer is then aware of where data gets written inside the image that may need to be persisted.
    • Setting environment variables like PATH, JAVA_HOME and sound defaults for the configuration of your image also help for an easy start.
    • Finally, you must specify with CMD or ENTRYPOINT how your image process starts.

    Here is an extract of the metadata available with the RHEL7 image. The complete set is available here.

    rhel7/rhel

    Env
        PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
        container=oci
    Cmd
        /bin/bash
    Labels
        com.redhat.component rhel-server-docker
        authoritative-source-url registry.access.redhat.com
        distribution-scope public
        vendor Red Hat, Inc.
        description The Red Hat Enterprise Linux Base image...
    [...]

    Extension points

    In part 2 we had the first glimpse at extension points. It is important to enable the image consumer to cover scenarios and configurations that either cannot be foreseen by the image creator or where the number of combinations would make it unmanageable. Extension points aim to avoid the need of rewriting layers you have created as part of your image.

    Injecting environment information at runtime

    This can be done in two ways: with setting environment variables and with mounting files into the container file system at startup.

    Environment variables can just be added to the deployment configuration or provided by ConfigMap. You may use this way to specify the address of a service that is called by your application.

    Files can be mounted on the container from ConfigMap to provide for instance logging configuration or from Secrets to provide certificates or other credentials required by the application.

    Configuration at build time

    If you have created a builder image, you may also want the user to inject the build configuration. You can, for instance, allow specifying a maven repository with an environment variable. This may however not be sufficient and your builder image should allow the user to inject complete settings.xml with the sources.

    You may have defined in an assemble script the compilation of the application and the configuration of the image. A level of flexibility in term of libraries and drivers provisioned into the final image can be provided with image sourcing (confer part 2 of this blog) but still, it is a good idea to allow the image user to adapt the build process by extending or replacing some of its logic. This can be done for instance by making scripts sourced or called in the assemble script replaceable by scripts provided by the user with the application sources.

    External builds

    In part 2 we also had a glimpse at allowing the user to build the application externally and to only have the container image built on OpenShift. The rationale behind that is that companies may have invested in automated and integrated CI/CD pipelines and related infrastructure before the introduction of container technologies. External builds allow them to go on with using this infrastructure as they are moving to a container as a service platform.

    There are two sensible approaches for that. The first one consists in streaming the application artifacts into the builder image from the CI tool (Jenkins for instance) through a binary build.

    The second approach is to download the artifacts from a company repository. This can be done with curl or wget but for java applications where you may already have maven in the builder image the maven dependencies plugin is a convenient way.

    Last updated: April 3, 2023

    Recent Posts

    • Expand Model-as-a-Service for secure enterprise AI

    • OpenShift LACP bonding performance expectations

    • Build container images in CI/CD with Tekton and Buildpacks

    • How to deploy OpenShift AI & Service Mesh 3 on one cluster

    • JVM tuning for Red Hat Data Grid on Red Hat OpenShift 4

    What’s up next?

     

    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