I am trying to build a image for one Springboot java application using gradle 8.0.2 and java 19jdk imag
e …build is getting successful and I am able to create a image but when I login to container java jar is not running …If I manually trigger java jar application is getting started but its not getting started from the Dockerfile I am using CMD [“java”, “-jar”, “myapp.jar”]
its not getting started when I deploy on Kubernetes using the created image my pod is going in crash loopback as service is not started and getting an error in pod saying Unable to access myapp.jar
I have used ENTRYPOINT as well the container starts application when I use docker run to create a container but that also didn’t work giving same error in Kubernetes POD
I am using user root and have given executable permission to myapp.jar …The jar is available in container
A few possible reasons why your app won’t run in a Docker container are:
Check if the path to your jar is correct in CMD or ENTRYPOINT. You can try opening an interactive shell in the container to verify that the myapp.jar file is actually in the container and accessible from the specified path.
Verify that the correct permissions are granted to the myapp.jar file in the container. If you are using a Dockerfile, add the chmod command for the myapp.jar file before CMD or ENTRYPOINT. For example: RUN chmod +x /path/to/myapp.jar
CMD [“java”, “-jar”, “/path/to/myapp.jar”]
Make sure that the version of Java you are using in the container is supported by your application. Check whether a specific version of Java is required to run your application and whether the version of Java you are using meets these requirements.
Hi Thanks for your reply…I tried all the above things but nothing seems working…When i create a docker container using the image I build i see my jar file in the specified path…when i run command as an argument in kubernetes deployment to check, the jar is not there.what could be the reason?
Yes it creates two jars now i am specifying jar name…App not running inside the container …kubernetes pod says unable to access jar error and goes in crashloopback.
Earlier i was using *.jar then i realised and changed it with specific jar name but still not working.In kubernetes pod jar itself was not there in the container.