Java not executable

Hi!

I’m new to Docker so I hope my question won’t sound too odd for you.

I want to create a docker image that contains a .jar-file, a downloaded jdk/jre package, a .yml-file (settings for the .jar-file) and a Dockerfile. When running the Dockerfile Docker should extract the jdk/jre package and start the java-file with certain arguments.

I’m working on Ubuntu 14.04.05, my Docker is 17.03.1-ce (API version: 1.27).

My working directory:
|
|_ Dockerfile
|_ jdk-8u131-linux-x64.tar.gz
|_ settings.yml
|_ project.jar

My Dockerfile:
FROM alpine:3.3
WORKDIR /app
ADD . /app
ENV NAME Transliteration
RUN tar -xvzf server-jre-8u131-linux-x64.tar.gz
ENV JAVA_HOME /app/jdk.1.8.0_131/
RUN ls -l /app/jdk1.8.0_131/bin
RUN /app/jdk.1.8.0_131/bin/java -version
CMD ["/app/jdk.1.8.0_131/bin/java -version"]

The error i get: /bin/sh: /app/jdk.1.8.0_131/bin/java: not found

So it seems that the java executable cannot be found, but a ls -l /app does give the correct folder structure (/app/jdk…/bin/java). What is the problem here?

could try to reduce the problem if you for now take a working alpine-java.

For example:
https://hub.docker.com/r/anapsix/alpine-java/

There just add your app and check if it is working.

Hi, think.

Thank you for your reply!

With pulling a alpine-java (or any java version, e.g. openjdk), the problem of course doesn’t occur. But for reasons of independency I want to avoid pulling a java version from any branch (because I don’t have control over what java version will be delivered). So, the core problem still exists: Why ain’t I able to start a delivered java runtime? I even used find -type f -name “java” to give the exact path during the execution of the docker image and still this path doesn’t work. To me it’s quite enigmatic.

you can use the working alpine-java as blueprint for your Dockerfile.
First use the original, then modify it until it exactly fits your needs.

Hi!

Thanks, I will try it.

FYI: The solution was to use the docker command “COPY” rather than “RUN cp”.

where did you use COPY rather than RUN cp, in the above docker file details i dont see any ‘RUN cp’ command
i am also facing same kind of issue with openjdk11.