How to get java openjdk 11 working in debian 9 docker?

I’ve been trying for hours to get Java 11 installed on a docker based on debian 9. It seems rather complicated due to oracle’s decision of requiring manual, "log-in"ed downloads, which is obviously not possible from within docker build.

all the repository problems aside, this is the code that I’ve gotten the furthest with:

RUN apt install -y software-properties-common && \
	add-apt-repository ppa:linuxuprising/java &&\
	apt-get update && \
	apt install -y --allow-unauthenticated oracle-java11-installer-local && \
	apt install oracle-java11-set-default-local

but at some point, there’s a terms and conditions prompt which requires manual input yes/no. It does not work, the docker build just freezes here regardless of user input.

Please share how you’re automatically installing java 11 on debian-based systems!

Well you should be able to suppress the license prompt using debconf… See https://askubuntu.com/a/637514 You might need to change/add a few other parameters for java11 but the link might lead you in the right direction.

Also you should be aware, that you are actually trying to install OracleJDK - not OpenJDK! And as Oracle lately changed there JDK licensing model, you should really check out, what you are agreeing to.

Another (much simpler) way would be to just base your image on one of the official OpenJDK images provided on Docker Hub - e.g. the one tagged 11-stretch.

1 Like