简体   繁体   English

将 JRE 复制到 docker 并运行 java 命令的问题

[英]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.

相关问题 从 Java 程序运行 Docker run 命令 - Run Docker run command from Java program Java JRE使用CentOS更新问题 - Java JRE Updating issue with CentOS Java for Eclipse编译JRE问题 - Java for Eclipse compilation JRE issue 是否有一个工具可以将JRE的副本与我的应用程序打包在一起,以便无论用户是否安装了Java,它都可以运行? - Is there a tool which will package a copy of the JRE with my application so that it can run regardless of whether or not the user has Java installed? 如何从命令行调用嵌入式jre以运行java应用程序 - How to call an embedded jre from command line in order to run java applications Google Cloud Platform管道/容器构建器在Spring Boot Java Application中使用COPY或ADD命令构建docker映像时出现问题 - Google Cloud Platform pipeline/container builder issue building docker image using COPY or ADD command for Spring Boot Java Application Java中的命令行工具连续运行多次,JRE不断打开/关闭,速度很慢 - Command line tool in Java gets run many times in a row, JRE keeps opening/closing, slow 如何设置NetBeans以使用特定命令运行Java应用程序(或使用其他JRE)? - How to setup NetBeans to run java application with specific command (or use other JRE)? 是否可以使用Java JRE 11运行Java applet? - Will it be possible to run Java applets with Java JRE 11? Java 32位JRE:此JRE可以运行64位程序吗? - Java 32 bits JRE: can this JRE run a 64 bit program?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM