0

I am new to docker and after building the image ,I got this when I try to run the image Error: Unable to access jar file

this is my docker file

FROM openjdk:8

COPY ./cm-service.jar /dockerimages/

EXPOSE 8080

ENTRYPOINT ["java","-jar","cm-service.jar"]

2 Answers2

2

Firstly, you are copying your jar to /dockerimages/ folder inside your docker container and trying to execute it in the root folder of the container.

FROM openjdk:8
COPY ./cm-auth-service-0.0.1.jar .
ENTRYPOINT exec java -Djava.security.egd=file:/dev/./urandom -jar /cm-auth-service-0.0.1.jar
EXPOSE 8085

You should add it to your root folder if you want to exec it from the root folder, if you want it to be in /dockerimages/ path than you should

FROM openjdk:8
COPY ./cm-auth-service-0.0.1.jar /dockerimages/
ENTRYPOINT exec java -Djava.security.egd=file:/dev/./urandom -jar /dockerimages/cm-auth-service-0.0.1.jar
EXPOSE 8085
  • thanks @Mert Kiray it worked. can you explain this part though for future. -exec java -Djava.security.egd=file:/dev/./urandom -jar / – Jafar Villan May 08 '20 at 15:52
  • Sure you can look for the accepted answer in the link for detailed answer in short description it is to ensure that your process to not be stuck at startup. https://stackoverflow.com/questions/58991966/what-java-security-egd-option-is-for – Mert Kıray May 08 '20 at 19:33
0

toy need WORKDIR /dockerimages/ before entrypoint

Balint
  • 295
  • 2
  • 11