<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/build-openjdk-container-images-locally-using-the-standalone-s2i-tool-lo5zc02ps" -->

---
title: Build OpenJDK container images locally using the...
description: This guide explains how to use the standalone S2I (Source-to-Image) CLI tool to build and test Red Hat build of OpenJDK container images locally, before...
canonical: https://daily.dev/posts/build-openjdk-container-images-locally-using-the-standalone-s2i-tool-lo5zc02ps
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Build OpenJDK container images locally using the standalone S2I tool | daily.dev
og:description: This guide explains how to use the standalone S2I (Source-to-Image) CLI tool to build and test Red Hat build of OpenJDK container images locally, before...
og:url: https://daily.dev/posts/build-openjdk-container-images-locally-using-the-standalone-s2i-tool-lo5zc02ps
og:image: https://api.daily.dev/og/posts/Lo5zc02Ps.png
og:image:alt: Build OpenJDK container images locally using the standalone S2I tool
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Build OpenJDK container images locally using the standalone S2I tool

**[Red Hat Developer](https://daily.dev/sources/rhdev)** · 19 min read · 0 upvotes · 0 comments

## Summary

This guide explains how to use the standalone S2I (Source-to-Image) CLI tool to build and test Red Hat build of OpenJDK container images locally, before deploying them to Red Hat OpenShift 4. It walks through practical S2I command examples including logging build details, customizing JVM garbage collection and memory settings via environment files, passing custom Maven repository configurations, and saving build parameters for repeatable builds. It also compares S2I standalone builds with OpenShift BuildConfig-based builds (source and binary builds), covers customizing the run-java.sh runtime script, discusses certificate injection options for TLS trust in Java apps using the service-ca and cert-manager operators, and provides troubleshooting tips for common S2I errors like missing tooling, Docker daemon issues, and permission errors.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://developers.redhat.com/articles/2026/09/23/build-openjdk-container-images-locally-using-standalone-s2i-tool>

## Questions this post answers

### How do I customize JVM garbage collection settings when building a Java container image with S2I?

Define MAVEN_OPTS in an S2I environment file, replacing default flags like -XX:+UseParallelGC with -XX:+UseG1GC and adjusting -XX:MaxRAMPercentage. Save this file as .s2i/environment in the source repository, then pass it to the build with the --environment-file flag so the S2I builder applies the custom JVM settings during the Maven build.

_Track S2I and OpenJDK build tips like this on daily.dev while tuning your own container builds._

### How do I use a custom run-java.sh script instead of the default one in an OpenJDK S2I image?

Deploy a custom script to /deployments/bin/run.sh inside the image; the container launches this script instead of the default run-java.sh. This lets you specify a different garbage collector, such as G1GC or Shenandoah, in place of the default ParallelGC used by the standard OpenJDK runtime script.

_daily.dev helps developers compare runtime tuning approaches like custom run-java.sh scripts._

### What is the difference between the service-ca operator and cert-manager for injecting certificates into Java applications on OpenShift?

The service-ca operator, bundled with OpenShift 4.x clusters, only assists with certificate injection and requires root access to run update-ca-trust for Java KeyStore (JKS) creation. The cert-manager operator instead lets a user create an Issuer and Certificate custom resource, and can generate a JKS keystore directly in the resulting Secret without requiring root.

_daily.dev is a place to compare certificate injection strategies before choosing one for a Java deployment._

## Similar posts on daily.dev

- [Dockerizing a Java 26 Project with Docker Init](https://daily.dev/posts/dockerizing-a-java-26-project-with-docker-init-n0yaflgv8) · Foojay.io · 30 upvotes · 0 comments
- [Building the Perfect Docker Image for a Java app](https://daily.dev/posts/building-the-perfect-docker-image-for-a-java-app-wf0dbjzj1) · Vaadin · 1 upvotes · 0 comments
- [Debugging image mode with Red Hat OpenShift 4.20: A practical guide](https://daily.dev/posts/debugging-image-mode-with-red-hat-openshift-4-20-a-practical-guide-wetoks9q8) · Red Hat Developer · 0 upvotes · 0 comments
- [Containerizing Java, Python, and JavaScript Apps - Multi-Stage Docker Builds, Non-Root Users, and Docker Hub Tagging](https://daily.dev/posts/containerizing-java-python-and-javascript-apps---multi-stage-docker-builds-non-root-users-and-do-ancbrg46f) · Medium · 22 upvotes · 0 comments

---

Tags: [#java](https://daily.dev/tags/java), [#containers](https://daily.dev/tags/containers), [#openshift](https://daily.dev/tags/openshift)

[View this post on daily.dev](https://daily.dev/posts/build-openjdk-container-images-locally-using-the-standalone-s2i-tool-lo5zc02ps)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Build OpenJDK container images locally using the standalone S2I tool","url":"https://daily.dev/posts/build-openjdk-container-images-locally-using-the-standalone-s2i-tool-lo5zc02ps","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/build-openjdk-container-images-locally-using-the-standalone-s2i-tool-lo5zc02ps"},"datePublished":"2026-09-23T14:03:18.287Z","dateModified":"2026-09-23T14:03:48.279Z","description":"This guide explains how to use the standalone S2I (Source-to-Image) CLI tool to build and test Red Hat build of OpenJDK container images locally, before...","image":"https://media.daily.dev/image/upload/s--1KxV4ohY--/f_auto/v1722860400/public/Placeholder%2007","thumbnailUrl":"https://media.daily.dev/image/upload/s--1KxV4ohY--/f_auto/v1722860400/public/Placeholder%2007","isAccessibleForFree":true,"articleSection":"Red Hat Developer","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Red Hat Developer","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/2a8895f3216c4900bdc455585a4ad3e4","url":"https://daily.dev/sources/rhdev"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/build-openjdk-container-images-locally-using-the-standalone-s2i-tool-lo5zc02ps","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"java,containers,openshift","timeRequired":"PT19M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Red Hat Developer","item":"https://daily.dev/sources/rhdev"},{"@type":"ListItem","position":3,"name":"Build OpenJDK container images locally using the standalone S2I tool"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/build-openjdk-container-images-locally-using-the-standalone-s2i-tool-lo5zc02ps#faq","mainEntity":[{"@type":"Question","name":"How do I customize JVM garbage collection settings when building a Java container image with S2I?","acceptedAnswer":{"@type":"Answer","text":"Define MAVEN_OPTS in an S2I environment file, replacing default flags like -XX:+UseParallelGC with -XX:+UseG1GC and adjusting -XX:MaxRAMPercentage. Save this file as .s2i/environment in the source repository, then pass it to the build with the --environment-file flag so the S2I builder applies the custom JVM settings during the Maven build. Track S2I and OpenJDK build tips like this on daily.dev while tuning your own container builds."}},{"@type":"Question","name":"How do I use a custom run-java.sh script instead of the default one in an OpenJDK S2I image?","acceptedAnswer":{"@type":"Answer","text":"Deploy a custom script to /deployments/bin/run.sh inside the image; the container launches this script instead of the default run-java.sh. This lets you specify a different garbage collector, such as G1GC or Shenandoah, in place of the default ParallelGC used by the standard OpenJDK runtime script. daily.dev helps developers compare runtime tuning approaches like custom run-java.sh scripts."}},{"@type":"Question","name":"What is the difference between the service-ca operator and cert-manager for injecting certificates into Java applications on OpenShift?","acceptedAnswer":{"@type":"Answer","text":"The service-ca operator, bundled with OpenShift 4.x clusters, only assists with certificate injection and requires root access to run update-ca-trust for Java KeyStore (JKS) creation. The cert-manager operator instead lets a user create an Issuer and Certificate custom resource, and can generate a JKS keystore directly in the resulting Secret without requiring root. daily.dev is a place to compare certificate injection strategies before choosing one for a Java deployment."}}]}
```

