Environment variables not resolved when Tomcat starts on OpenShift using "webserver31-tomcat7-openshift/images/1.4-10" image

Solution Verified - Updated -

Issue

  • After upgrading the base image from webserver31-tomcat7-openshift/images/1.2-16.1539812396 to webserver31-tomcat7-openshift/images/1.4-10, it is noticed the environment variables stopped to be resolved correctly.
  • Issue seen with Image : webserver31-tomcat7-openshift/images/1.4-10. On passing the new environment variable as below (with a backslash \), here host name is not resolved :
# oc set env dc/webserver31-tomcat7-openshift CATALINA_OPTS_APPEND="-Dcom.test.instanceName=\${HOSTNAME}"
# oc exec webserver31-tomcat7-openshift-2-4469m env|egrep 'HOSTNAME|CATALINA_OPTS_APPEND'
HOSTNAME=webserver31-tomcat7-openshift-2-4469m
CATALINA_OPTS_APPEND=-Dcom.test.instanceName=${HOSTNAME}
# oc logs webserver31-tomcat7-openshift-2-4469m|grep "com.test.instanceName"
2019-09-13 02:17:04,008 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Dcom.test.instanceName=${HOSTNAME}
  • No Issue with Older Image : webserver31-tomcat7-openshift/images/1.2-16.1539812396. On passing the new environment variable as below (with a backslash \), here host name is resolved :
# oc set env dc/webserver31-tomcat7-openshift CATALINA_OPTS_APPEND="-Dcom.test.instanceName=\${HOSTNAME}"
# oc exec webserver31-tomcat7-openshift-2-6j5jg env|egrep 'HOSTNAME|CATALINA_OPTS_APPEND'
HOSTNAME=webserver31-tomcat7-openshift-2-6j5jg
CATALINA_OPTS_APPEND=-Dcom.test.instanceName=${HOSTNAME}
# oc logs webserver31-tomcat7-openshift-2-6j5jg|grep "com.test.instanceName"
2019-09-13 02:25:39,218 [main] INFO  org.apache.catalina.startup.VersionLoggerListener- Command line argument: -Dcom.test.instanceName=webserver31-tomcat7-openshift-2-6j5jg

Environment

  • OpenShift Container Platform
    • 3.11

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In