Reputation: 15929
I am trying to build a Docker Container (using a Dockerfile) with a specific version of Java 8 on it. A lot of the examples target the latest release.
RUN add-apt-repository -y ppa:webupd8team/java
RUN apt-get update -y
RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
RUN apt-get install -y oracle-java8-installer
I have a need where i want to control the specific version of Java that my container is provisioned. Any hint on how to achieve this? For Example Java 8 update 31.
Upvotes: 9
Views: 23608
Reputation: 341
For Docker Container OS: Cent 6.6
Use this command in your Dockerfile to update your JDK version to 1.8:
RUN touch /var/lib/rpm/* \
&& yum -y install java-1.8.0-openjdk-devel
Upvotes: 0
Reputation: 77961
Another option is to use the official Java image from the Docker Hub Registry
Admittedly it doesn't offer the Oracle JDK due to licensing restrictions, but it's the simplest way to integrate Java into your Docker workflow.
Upvotes: 0
Reputation: 16041
As most PPA packages pack the latest stable version, I would recommend installing Java manually from Oracle, just like in this answer.
You can do all the work in the script too, the steps are:
wget
,tar -xz
,update-alternatives
to set is as defaultUpvotes: 9