I tested my ApachedMQ image on Ubuntu and it works fine with Docker. On Openshift deploying the same image does not work. It should work out of the box, just like Ubuntu, but it always complains about missing directories in the pod, or lack of permissions on directories in the pod. Below you will see errors regarding the former.
I am using the FREE edition of Openshift online v3.x I am only using the console to deploy from the image. Below just a sample of the log messages when the pod is ramping up for the deployment.
java.io.FileNotFoundException: /opt/activemq/data/activemq.log (Permission denied)
Caused by: java.io.IOException: Failed to create directory '/opt/activemq/data/kahadb'
Any help would be much appreciated, as this image should IMO, be deployable from the console without any YAML and oc CLI necessary. Some log trace information: INFO: Loading '/opt/activemq/bin/env' INFO: Using java '/docker-java-home/jre/bin/java' INFO: Starting in foreground, this is just for debugging purposes (stop process by pressing CTRL+C) INFO: Creating pidfile /opt/activemq/data/activemq.pid bin/activemq: 484: bin/activemq: cannot create /opt/activemq/data/activemq.pid: Permission denied Java Runtime: Oracle Corporation 1.8.0_141 /usr/lib/jvm/java-8-openjdk-amd64/jre Heap sizes: current=62976k free=58714k max=932352k JVM args: -Xms64M -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=/opt/activemq/conf/login.config -Dcom.sun.management.jmxremote -Djava.awt.headless=true -Djava.io.tmpdir=/opt/activemq/tmp -Dactivemq.classpath=/opt/activemq/conf:/opt/activemq/../lib/: -Dactivemq.home=/opt/activemq -Dactivemq.base=/opt/activemq -Dactivemq.conf=/opt/activemq/conf -Dactivemq.data=/opt/activemq/data Extensions classpath: [/opt/activemq/lib,/opt/activemq/lib/camel,/opt/activemq/lib/optional,/opt/activemq/lib/web,/opt/activemq/lib/extra] ACTIVEMQ_HOME: /opt/activemq ACTIVEMQ_BASE: /opt/activemq ACTIVEMQ_CONF: /opt/activemq/conf ACTIVEMQ_DATA: /opt/activemq/data log4j:ERROR setFile(null,true) call failed. java.io.FileNotFoundException: /opt/activemq/data/activemq.log (Permission denied) ... log4j:ERROR setFile(null,true) call failed. java.io.FileNotFoundException: /opt/activemq/data/audit.log (Permission denied) ... Loading message broker from: xbean:activemq.xml INFO | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1@5bcab519: startup date [Fri Mar 16 21:10:18 UTC 2018]; root of context hierarchy WARN | Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.activemq.xbean.XBeanBrokerService#0' defined in class path resource [activemq.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: java.io.IOException: Failed to create directory '/opt/activemq/data/kahadb' ERROR | Failed to load: class path resource [activemq.xml], reason: Error creating bean with name 'org.apache.activemq.xbean.XBeanBrokerService#0' defined in class path resource [activemq.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: java.io.IOException: Failed to create directory '/opt/activemq/data/kahadb' org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.activemq.xbean.XBeanBrokerService#0' defined in class path resource [activemq.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: java.io.IOException: Failed to create directory '/opt/activemq/data/kahadb'
I corrected the image. The docker file can be found here on my fork: https://github.com/beezerbt/docker-activemq/tree/master/5.14.5-openshift-v3.9.14
The image for the above can be found here: https://hub.docker.com/r/beezer/openshift-ready-mq/tags/ Tag::[5.14.5-3.9.14]
Finally, since the image has an ephemeral persistence, a volume can be mapped to /app
within the openshift cluster quite easily; however do remember that you must set the volume mount point as something OTHER than /app and then further down in the volume definition on Openshift console, specify where in the container it should be mapped to...which is then /app.
In order for the image to successfully be deployed, the following have to be done on the cluster:
oc adm policy add-scc-to-user anyuid -z default -n myproject --as system:admin
I will continue to find other alternatives including a rebuild of the image, creating a pod with the requisite permissions for the $APACHEMQ_DATA directory.
Below proof of the route working on the playground instance. It is o.k. to paste it as the playground will expire in the next 10 minutes.