英文:
Change from JRE to JDK in Docker container
问题
Here is the translated content of your Dockerfile and the related text:
我正在使用tomcat,jre 8(openjdk),以alpine linux为基础镜像。
我的Dockerfile如下:
FROM tomcat:8.5.39-jre8-alpine
RUN rm -rf /usr/local/tomcat/webapps/*
COPY target/openjdk8-8.252.09-r0.apk /usr/local/tomcat/.
RUN apk add --allow-untrusted /usr/local/tomcat/openjdk8-8.252.09-r0.apk
ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk
ENV PATH=/usr/local/tomcat/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/bin
RUN export JAVA_HOME
RUN export PATH
我想要使用jdk8而不是jre8。
为了做到这一点,我已经下载了相同版本的JDK8并在alpine linux上安装它。
英文:
I am using tomcat, jre 8(openjdk),alpine linux as base image.
My Dockerfile is follow:
FROM tomcat:8.5.39-jre8-alpine
RUN rm -rf /usr/local/tomcat/webapps/*
COPY target/openjdk8-8.252.09-r0.apk /usr/local/tomcat/.
RUN apk add --allow-untrusted /usr/local/tomcat/openjdk8-8.252.09-r0.apk
ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk
ENV PATH=/usr/local/tomcat/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/bin
RUN export JAVA_HOME
RUN export PATH
I want to use jdk8 instead of jre8.
In order to do that, I have downloaded same version of JDK8 and install it on alpine linux.
COPY target/openjdk8-8.252.09-r0.apk /usr/local/tomcat/.
RUN apk add --allow-untrusted /usr/local/tomcat/openjdk8-8.252.09-r0.apk
And to make sure desired java(JDK8) is picked up, I set JAVA_HOME and PATH.
ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk
ENV PATH=/usr/local/tomcat/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/bin
But still when I run Tomcat(when I run container),
/usr/lib/jvm/java-1.8-openjdk/jre
is logged in console meaning that original JRE is still in use.
I have read this one.
But I do not understand clearly what he means by it.
Is there any workaround or any way to get it working?
Or where did I make mistake?
Cheers
答案1
得分: 1
我正在使用OpenJDK 8与Alpine在Docker镜像中,Docker文件如下:
FROM alpine:3.11.3
ENV LANG=C.UTF-8 \
JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk \
PATH=$PATH:/usr/lib/jvm/java-1.8-openjdk/bin/
RUN set -x apk add --no-cache openjdk8
英文:
I am using OpenJDK8 with Alpine in Docker image with a following Docker:
FROM alpine:3.11.3
ENV LANG=C.UTF-8 \
JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk \
PATH=$PATH:/usr/lib/jvm/java-1.8-openjdk/bin/
RUN set -x apk add --no-cache openjdk8
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论