Dynamically set JAVA_HOME of docker container

前端 未结 4 1365
粉色の甜心
粉色の甜心 2020-12-21 10:24

My docker container requires JAVA_HOME to be set. I have added it to the Dockerfile as below

ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/jre
         


        
4条回答
  •  庸人自扰
    2020-12-21 10:49

    It's possible add the JAVA_HOME in a ENV Dockerfile instruction. But if the Java package is updated you have to change the ENV JAVA_HOME in your Dockerfile.

    But I found a method to set the JAVA_HOME automatically without update the Dockerfile.

    RUN export JAVA_HOME="$(dirname $(dirname $(readlink -f $(which java))))"
    

    I hope this can help you.

提交回复
热议问题