0

I need to run a java programm inside the python3-onbuild image (it is based on debian jessie) . I extended the dockerfile with the installation of java, but if i try to print out the version it results in

System error: exec: "java": executable file not found in $PATH

I created a repository with my code.

My Dockerfile:

FROM python:3-onbuild
ONBUILD RUN ["apt-get", "install", "-y", "openjdk-7-jre"]

# Define commonly used JAVA_HOME variable
ONBUILD ENV JAVA_HOME /usr/java/default
ONBUILD ENV PATH $PATH:$JAVA_HOME/bin

CMD ["java", "-version"]

Any idea whats wrong and how I can fix it ?

1 Answer 1

2

I think you are misunderstanding ONBUILD. From the docs:

The ONBUILD instruction adds to the image a trigger instruction to be executed at a later time, when the image is used as the base for another build. The trigger will be executed in the context of the downstream build, as if it had been inserted immediately after the FROM instruction in the downstream Dockerfile.

So, when docker build encounters the FROM instruction in your Dockerfile, it will execute on ONBUILD instructions from the python image. In your Dockerfile, the ONBUILD instructions are never executed, as they would only be triggered if the image is referenced from another Dockerfile.

I think you just meant to use RUN instead of ONBUILD, but I'm not sure why you are trying to use ONBUILD at all.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.