Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
248 views
in Technique[技术] by (71.8m points)

image - run 2 java process in DOCKERFILE

I have an ignite(gridgain-community) statefulset cluster in kuberntes. I created sucssfuly image from the below docker (the cmd runs jmx exporter) :

FROM gridgain/community:8.8.1-slim

USER root
RUN mkdir -p /opt/jmx_exporter/

COPY ./jmx/*  /opt/jmx_exporter/
RUN chmod 700 /opt/jmx_exporter/start.sh
CMD ["/bin/sh", "/opt/jmx_exporter/start.sh"]

but when I start the chart from this image the pod is running but not ready :

NAME          READY   STATUS    RESTARTS   AGE
online-db-0   0/1     Running   3          4m2s

and in describe:

  Normal   Started    51s                kubelet, samppc01srv01kbr002.novalocal  Started container online-db
  Warning  Unhealthy  12s (x3 over 32s)  kubelet, samppc01srv01kbr002.novalocal  Liveness probe failed: Get http://10.233.109.23:8080/ignite?cmd=version: dial tcp 10.233.109.23:8080: connect: connection refused
  Normal   Killing    12s                kubelet, samppc01srv01kbr002.novalocal  Container online-db failed liveness probe, will be restarted
  Warning  Unhealthy  9s (x3 over 29s)   kubelet, samppc01srv01kbr002.novalocal  Readiness probe failed: Get http://<IP>/ignite?cmd=probe: dial tcp <ip>:8080: connect: connection refused

when I check in the pod I see only jmx is up and ignite java is down it did worked when I start jmx manually on ignite container:

bash-4.4# ps -ef | grep java
    6 root      0:01 java -Djava.net.preferIPv4Stack=true -jar /opt/jmx_exporter/jmx_prometheus_httpserver-0.12.0-jar-with-dependencies.jar 5556 /opt/jmx_exporter/config.yml
   26 root      0:00 grep java

start.sh - the java_script

!/bin/sh

if [ -z "$SERVICE_PORT" ]; then
 

     SERVICE_PORT=5556
    fi
    
    if [ -z "$JVM_OPTS" ]; then
      JVM_OPTS="-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=5555"
    fi
    
    if [ -z "$CONFIG_YML" ]; then
      CONFIG_YML=/opt/jmx_exporter/config.yml
    fi
    
    VERSION=0.12.0
    
    java $JVM_OPTS -jar /opt/jmx_exporter/jmx_prometheus_httpserver-$VERSION-jar-with-dependencies.jar $SERVICE_PORT $CONFIG_YML

nothing is in the logs can someone assist why this happenes?

question from:https://stackoverflow.com/questions/65891378/run-2-java-process-in-dockerfile

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I created a startall.sh script which run both ignite process and jm scrpts like below:

#!/bin/sh

set -m


/opt/jmx_exporter/start.sh &

/bin/sh -c ${IGNITE_HOME}/run.sh

and then edit my dockefile to run only the wrapper script:

FROM gridgain/community:8.8.1-slim
USER root
RUN mkdir -p /opt/jmx_exporter/ 
COPY ./jmx/*  /opt/jmx_exporter/ 
RUN chmod 700 /opt/jmx_exporter/start.sh 
CMD ["/bin/sh", "/opt/jmx_exporter/startall.sh" ]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...