Change JAVA_HOME in docker

If your base image contains by default OpenJDK and If you want to use OracleJDK in your image just add the below command to your dockerfile and build the image and boom your image will have oracle JDK.

RUN yum -y remove java***
RUN yum localinstall -y jdk-8u212-linux-x64.rpm && \
    echo "JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")" | tee 
    -a /etc/profile && source /etc/profile && echo $JAVA_HOME && \
    rm jdk-8u212-linux-x64.rpm && \ 
    alternatives --set java /usr/java/jdk1.8.0_212-amd64/jre/bin/java

You can simply set/change environment variables of your docker image by using the ENV command in your Dockerfile:

ENV JAVA_HOME /path/to/java