繁体   English   中英

在 DOCKERFILE 中运行 2 个 java 进程

[英]run 2 java process in DOCKERFILE

我在 kuberntes 中有一个 ignite(gridgain-community) statefulset 集群。 我从下面的 docker 创建了成功的图像(cmd 运行 jmx 导出器):

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"]

但是当我从此图像启动图表时,吊舱正在运行但尚未准备好:

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

并在描述:

  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

当我检查 pod 时,我看到只有 jmx 启动并点燃 java 已关闭,当我在 ignite 容器上手动启动 jmx 时它确实有效:

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 - 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

日志中没有任何内容,有人可以协助为什么会发生这种情况吗?

我创建了一个 startall.sh 脚本,它同时运行 ignite 进程和 jm scrpts,如下所示:

#!/bin/sh

set -m


/opt/jmx_exporter/start.sh &

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

然后编辑我的 dokefile 以仅运行包装脚本:

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" ]

问题未解决?试试以下方法:

在 DOCKERFILE 中运行 2 个 java 进程

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2023 STACKOOM.COM