Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Java 11 on Dockerfile?

Tags:

java

docker

I am trying to make a Dockerfile where Java11 has to be "loaded".

However, when I try:

RUN add-apt-repository -y ppa:linuxuprising/java 

then I get this error:

/bin/sh: 1: add-apt-repository: not found The command '/bin/sh -c add-apt-repository -y ppa:linuxuprising/java' returned a non-zero code: 127

My question is how could I "install" Java11 on Docker?

like image 304
hariszaf Avatar asked Nov 30 '22 14:11

hariszaf


2 Answers

Assuming that is not possible to base your image on a OpenJDK official image.

Take a look to how it is installed in the official image Dockerfile (or the repository).

There are also alternatives images, like AdoptOpenJDK (Dockerfile based on Ubuntu)

like image 156
Gonzalo Matheu Avatar answered Dec 05 '22 08:12

Gonzalo Matheu


For CentOS in your docker image you still can use:

FROM centos
RUN yum install -y java-11
like image 31
Jochen Gebsattel Avatar answered Dec 05 '22 06:12

Jochen Gebsattel