首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在DOCKERFILE中运行2个java进程

在DOCKERFILE中运行2个java进程
EN

Stack Overflow用户
提问于 2021-01-26 03:42:59
回答 1查看 72关注 0票数 1

我在kuberntes中有一个ignite(Gridgain Community)状态集集群。我从下面的docker创建了sucssfuly镜像( cmd运行jmx exporter):

代码语言:javascript
复制
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"]

但是当我从这个图像开始图表时,pod正在运行,但还没有准备好:

代码语言:javascript
复制
NAME          READY   STATUS    RESTARTS   AGE
online-db-0   0/1     Running   3          4m2s

在describe中:

代码语言:javascript
复制
  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在打开,ignite java在关闭,当我在ignite容器上手动启动jmx时,它起作用了:

代码语言:javascript
复制
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

代码语言:javascript
复制
!/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

日志里什么都没有,有没有人能帮助解释为什么会发生这种情况?

EN

回答 1

Stack Overflow用户

发布于 2021-01-27 17:58:33

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

代码语言:javascript
复制
#!/bin/sh

set -m


/opt/jmx_exporter/start.sh &

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

然后编辑我的dockefile,只运行包装器脚本:

代码语言:javascript
复制
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" ]
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65891378

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档