Docker run failed : Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "java": executable file not found in $PATH: unknown

The below is my DockerFile

FROM centos/systemd
MAINTAINER broadcom.com
COPY discoveryservice-99.99.nextgen-SNAPSHOT.jar /opt/kubernetes/discoveryservice.jar
COPY logback.xml /usr/local/openshift/logback.xml
COPY nimsoft/jre/jre8u312b07 /opt/nimsoft/jre/jre8
EXPOSE 8080
RUN ["chmod","+x","/opt/nimsoft/jre/jre8/bin/java"]
CMD ["java", "-jar", "/opt/kubernetes/discoveryservice.jar"]

While running the jar file, I am getting the OCI runtime create failed error:exec: “java”: executable file not found in $PATH:
Can anyone suggest me on solving this

Why did you choose to run java in a systemd container when you need java and you probably don’t need systemd? Java is not installed in the systemd image.

PS.: Please, don’t share photos of terminal outputs if you can copy and paste it in your message. Also use the code block button (</> above the message text area) to insert code and terminal outputs. I fixed your post this time

1 Like

@rimelek I think you missed the COPY instruction.

You either need to add the path where the java executable is, to the PATH variable with something like this ENV: PATH=${PATH}:/opt/nimsoft/jre/jre8/bin/ or use the absolute path to the java executable in the RUN instruction: CMD ["/opt/nimsoft/jre/jre8/bin/java", "-jar", "/opt/kubernetes/discoveryservice.jar"]

The problem you experience is not container specific. It is linux specific. The same would happen on any linux host without installed java, where you extract a java distribution to an arbitrary folder and expect that when you type the command java that it somehow finds the java executable… This is not how it works, an executable must be either addressed absolute, relative to your current path or must be in a folder that is in the $PATH variable.

1 Like

Indeed. Thanks for pointing that out :slight_smile:

You probably mean CMD instruction, but indeed, the RUN instruction before CMD uses the exec form that we usually use only for CMD. @vijayaraghavanvk045000 this way that chmod command would be an argument of the entrypoint if the systemd image had an entrypoint, but it doesn’t.

Although I really missed that COPY instruction, I would still use a java image instead of a 4-year-old, not up-to-date systemd image.

The fact that you want to run some discoveryservice for Kubernetes makes me more curious why it is based on Systemd.