[英]Issue with copy JRE into docker and run java command
I am copying the working version of the JRE directory into docker and trying to run /JRE/bin/java.我正在将 JRE 目录的工作版本复制到 docker 并尝试运行 /JRE/bin/java。 But it throws ash: java not found error.
但它抛出ash: java not found错误。 I am doing the same in a linux VM .
我在 linux VM 中做同样的事情。 Just copying the JRE folder and executing java command which works fine in VM.
只需复制 JRE 文件夹并执行在 VM 中运行良好的 java 命令。 I don't want to download JRE from anywhere.
我不想从任何地方下载 JRE。 Want this specific JRE bundled.How to resolve this.
想要捆绑这个特定的 JRE。如何解决这个问题。
I entered into the shell console and navigated to the JRE/bin/ directory and executed "java".我进入 shell 控制台并导航到 JRE/bin/ 目录并执行“java”。 even then it fails .
即使这样它也失败了。 The error is same ash: java not found error.
错误是相同的ash: java not found错误。
Dockerfile: Dockerfile:
FROM alpine:latest
ENV HOME=/root \
DEBIAN_FRONTEND=noninteractive \
LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8 \
LC_ALL=C.UTF-8 \
DISPLAY=:0.0 \
DISPLAY_WIDTH=1024 \
DISPLAY_HEIGHT=768
RUN apk --update --upgrade add \
bash \
fluxbox \
x11vnc \
xterm \
xvfb
COPY MyJavaApp MyJavaApp/
WORKDIR /MyJavaApp
ENV PATH="./JRE/bin:${PATH}"
When are you copying the JRE directory to the docker?你什么时候把JRE目录复制到docker? ie Docker build time or after spinning up the Docker container?
即 Docker 构建时间还是在启动 Docker 容器之后?
Looks like you are correctly copying the local Java directory to the image, however the current location cannot access the java binaries, thus, make sure to set the PATH.看起来您正确地将本地 Java 目录复制到图像,但是当前位置无法访问 Java 二进制文件,因此,请确保设置 PATH。 It should be something like,
它应该是这样的,
RUN export PATH=/JRE/bin:${PATH}
or pass the path to the ENV in the Dockerfile,或将路径传递到 Dockerfile 中的 ENV,
ENV PATH="/JRE/bin:${PATH}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.