Assuming that there is a CentOS Dockerfile:
FROM centos
What is the right way of adding OpenJDK 8 for it ?
I have tried to use similar approach as for Fedora https://github.com/projectatomic/docker-fedora-images/blob/master/java-openjdk-8/Dockerfile
But when I run the image java version is "1.7.0_111", even though it is expected to be JDK 8:
docker run -i -t <image> /bin/bash
[user@2fcc1e47c3cd projects]$ java -version
java version "1.7.0_111"
OpenJDK Runtime Environment (rhel-2.6.7.2.el7_2-x86_64 u111-b01)
OpenJDK 64-Bit Server VM (build 24.111-b01, mixed mode)
There are many sources which describe Oracle JDK installations, but I was not able to find any relevant instructions for OpenJDK
Seems to be as easy as this:
FROM centos
RUN yum install -y \
java-1.8.0-openjdk \
java-1.8.0-openjdk-devel
ENV JAVA_HOME /etc/alternatives/jre
.
.
When JDK for development is installed, then JAVA_HOME should point to JDK instead of JRE.
RUN yum install -y \
java-1.8.0-openjdk \
java-1.8.0-openjdk-devel
ENV JAVA_HOME /usr/lib/jvm/java-1.8.0-openjdk/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With