Docker Community Forums

Share and learn in the Docker community.

How to use host machine jdk in a container while creating a docker image

Below is my DockerFile content

FROM centos

ADD jdk-11.0.7_linux-x64_bin.tar.gz /opt/java

ENV JAVA_HOME /opt/java/jdk-11.0.7

ENV PATH $PATH:/opt/java/jdk-11.0.7/bin

RUN ls -l /opt/java/jdk-11.0.7

RUN java -version

ADD build/libs/CatalogModel-1.0.jar CatalogModel-1.0.jar


ENTRYPOINT [“java”, “-jar”, “CatalogModel-1.0.jar”]

As seen above i am adding jdk in this line -->ADD jdk-11.0.7_linux-x64_bin.tar.gz /opt/java

Instead of this if i want to create docker image and make it use host jdk without adding it like how i have done.Is this possible?

How would that even make sense?