简体   繁体   中英

Dockerfile: How to put a .jar in the PATH

I would like to put a .jar in the VM PATH (in Linux) but when I run the container, it shows me that the link put in the PATH is not found.

Dockerfile :

FROM amancevice/pandas:1.2.1
RUN apt-get update -yq \
&& apt-get install nodejs -yq \
&& apt-get clean -y 
FROM store/oracle/serverjre:1.8.0_241-b07
COPY *.jar /Files/
CMD [ "PATH=$PATH:/Files/json-simple-1.1.jar" ]

CMD you probably want is something like:

CMD ["java","-jar","/Files/json-simple-1.1.jar"]

If what you really wanted is to run the jar - then PATH changes are not needed as java already is in the PATH


But, if your jar can run directly as an executable (or as a Java script) and that is what you want - run it directly - check that the *.jar files you copy over have executable permission in the Docker image.

RUN chmod u+x /Files/*.jar

Also PATH does not allow to add executable files to it directly - PATH=$PATH:/Files/json-simple-1.1.jar does not work. PATH allows only directories added to it, and searches in those directories for files that are executable.

So:

ENV PATH="${PATH}:/Files"

Should work and expand the environment variable properly further on. Then, if jar is executable - it can be invoked by the literal name json-simple-1.1.jar as expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM