Olumide
Olumide

Reputation: 5809

Docker cannot find JVM

The container that I'm trying to build requires the JVM which I have installed at /usr/lib/jvm/java-8-openjdk-amd64. I've added the line

RUN ./installer.sh --javahome /usr/lib/jvm/java-8-openjdk-amd64

to to my Dockerfile. However I'm still getting the error message:

Searching for JVM on the system...
Java Runtime Environment (JRE) was not found at the specified location /usr/lib/jvm/java-8-openjdk-amd64
The command '/bin/sh -c ./installer.sh --javahome /usr/lib/jvm/java-8-openjdk-amd64' returned a non-zero code: 4

Update

Here's the entire Docker file

FROM scratch
MAINTAINER Oracle Linux Product Team <[email protected]>
ADD oraclelinux-7.3-rootfs.tar.xz /

# overwrite this with 'CMD []' in a dependent Dockerfile
CMD ["/bin/bash"]

RUN useradd me
ADD . .

RUN ./installer.sh --javahome /usr/lib/jvm/java-8-openjdk-amd64

Upvotes: 0

Views: 1555

Answers (2)

Djelibeybi
Djelibeybi

Reputation: 78

You could also consider using the official OpenJDK image from the Docker Hub as the basis for your Dockerfile instead of building everything from scratch.

If you absolutely need to use Oracle Linux as the user space inside your container, you should either extend the Oracle OpenJDK image or the Oracle Java 8 JDK instead.

It's very rare that you'd want to build an image FROM scratch.

Upvotes: 0

BMitch
BMitch

Reputation: 263489

The oracle linux image you are trying to use does not include java:

$ docker run -it --rm oraclelinux:7.3 /bin/bash
[root@f95110d33bde /]# ls -al /usr/lib/jvm/java-8-openjdk-amd64
ls: cannot access /usr/lib/jvm/java-8-openjdk-amd64: No such file or directory
[root@f95110d33bde /]# ls /usr/lib/
binfmt.d/       dracut/         kernel/         modprobe.d/     python2.7/      sse2/           systemd/        udev/
debug/          games/          locale/         modules-load.d/ rpm/            sysctl.d/       tmpfiles.d/     yum-plugins/
[root@f95110d33bde /]# find . -name java
./etc/pki/ca-trust/extracted/java
./etc/pki/java

If you are installing java, you'll need to include the reproducible steps you've taken to do this.

Note, you would typically build your image FROM oraclelinux:7.3 rather than reproducing the upstream part of this image build.

Upvotes: 1

Related Questions