Issue
Inside of my Dockerfile I am trying to simply add Maven to my image that already has a proper version of Java8. As in:
RUN apt-get install -y maven
When I do this, the install for maven
brings along Java11 even thought I simply want to install Maven for the Java8 JDK I already have installed on the box. I am hoping there is some obvious solution to this that is clean and simple. I thought at first that the apt-mark hold
might work, but I cannot figure out the name of the package to hold. For example, I tried
RUN apt-mark hold default-jdk default-jre \
&& apt-get install -y maven
It seems very unfriendly of maven to install Java11 without any switch to tell it to either a) install Java8 or do not install Java and just trust that it is installed already.
Any ideas on how to install maven on ubuntu without this issue?
Solution
In my situation, I found I could stop Java11
from being installed by putting using the following 3 packages on hold:
RUN apt-mark hold default-jdk \
&& apt-mark hold default-jre \
&& apt-mark hold default-jre-headless \
&& apt-get install -y maven
At least for my situation (Corretto Java8 JDK
installed on a Ubuntu 20
image) that marking these packages as on hold kept the maven
install from updating the java version to 11.
Answered By - Kim Gentes