How to install a specific version of Java 8 using Dockerfile

21,999

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:

  • get the tarball with wget,
  • untar it with tar -xz,
  • use update-alternatives to set is as default
Share:
21,999
Marco
Author by

Marco

Happy coder, system architect, software geek, cloud believer, tech guy, open-source enthusiasts, wannabe cooking chef, likes to travel, meet new people, share knowledge, and watch movies/series.

Updated on July 09, 2022

Comments

  • Marco
    Marco almost 2 years

    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.