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
Can someone please suggest
Looks like the folder where the java binary is located is not in the PATH.
I assume if the workdir is not set to the path where the jar is located, you should still get a dying container, but you should at least see logs.
Below is my dockerfile
Below is my Dockerfile for reference.
FROM gradle:8.0.2-jdk19 AS build
COPY build.gradle settings.gradle gradlew ./
COPY gradle ./gradle
COPY src ./src
RUN ./gradlew build -x test
COPY --from=build /home/gradle/src/build/libs/*.jar app.jar
CMD [“java”, “-jar”, “./app.jar”]
Is there a way for us to replicate it?
For example, commands to start containers, k8s manifest, etc.
Below is my k8’s manifest
- name: test
args: [“-c”, “-jar”, “app.jar”]
- containerPort: 8080
Thank you. However, I could not reproduce it in my environment.
If the pod log is [Error: Unable to access jarfile myapp.jar], I think it is most likely that [/app/myapp.jar] does not exist.
Please check the following two things
- Log in to the container container and make sure that
- Make sure that the image you are using with Kubernetes is up-to-date
If you are still unable to do so, re-create the image and run
I created a Docker image using above Dockerfile and logged in to the container to check if app.jar is available.
app.jar file is available in Docker container whereas if I use the same image to deploy on Kubernetes and use command as an argument to check the jar and start its giving error as unable to access jar
Can you please paste the command you executed and the log you checked?