Reputation: 143
kubectl get pods -n abc
NAME READY STATUS RESTARTS AGE
abc-v2-78b59ccc4f-85xgr 0/1 CrashLoopBackOff 27 129m
Facing below error:
> ➜ ~ kubectl logs -f abc-v2-78b59ccc4f-85xgr -n
Error: Unable to access jarfile abc.jar
I am assuming either jar is not present or required access is missing. Pls guide me here, how to proceed.
Edit 1: As suggested by @howard-roark, Jar is available inside container, getting the same error message.
Edit 2: Check results now with .jar in java command
Edit 4: Ideally there should be only one instance with running status.
Upvotes: 2
Views: 6450
Reputation: 1
I am facing the issue while running the docker image, attached the Dockerfile content here :
FROM eclipse-temurin:21 RUN apt-get update VOLUME /tmp EXPOSE 8080 ADD target/spring-boot-aws-exe.jar spring-boot-aws-exe.jar ENTRYPOINT [ "java", "-jar", "/spring-boot-aws-exe.jar " ]
The error while running the docker command from git bash: Unable to access jarfile
please see below command which I have run it from GIT bash **** MINGW64 ~/Downloads/springjpa (master) $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE springjpa latest dcb2d2eabe26 18 seconds ago 1.09GB eclipse-temurin 21 1f1cad73899c About an hour ago 863MB
**** MINGW64 ~/Downloads/springjpa (master) $ docker run -p 8080:8080 dcb2d2eabe26 Error: Unable to access jarfile /spring-boot-aws-exe.jar
****MINGW64 ~/Downloads/springjpa (master)
Upvotes: 0
Reputation: 146
In my case I had to modify my Dockerfile and changing the working directory by using the WORKDIR
before the ENTRYPOINT
e.g:
ARG JAR_FILE=my-service/build/libs/*.jar
COPY $JAR_FILE /apps/my-service/my-service-web.jar
WORKDIR /apps/my-service
ENTRYPOINT ["java", "-jar", "my-service-web.jar"]
Upvotes: 0
Reputation: 1840
If you mount a config-map resource or other volume on top of where the dockerized-application would normally find its .jar file, this will happen. Be sure to mount in a different place, that it wouldn't overwrite a directory in the container.
A good way to troubleshoot is to override the command that is run in the pod to be "sleep infinity." Once the pod is running, run:
kubectl exec -it runningpod -- /bin/sh
... and look around. Also consider running the docker container directly, looking around.
docker run -i --tty --entrypoint=/bin/sh podcontainerimage
Upvotes: 1
Reputation: 4326
Kubernetes is a Container Orchestrator. It runs your images as Containers. The error you are showing looks like an application error and not a Kubernetes error. The way I would approach this is:
docker run -it <image> /bin/bash
Or you can do a similar command via Kubernetes to exec into your pod:
kubectl run -i --tty testjavacontainer --image=<image> -- /bin/bash
In short, I would approach this as a standard java error, with the nuance that it happens to run in a container.
Upvotes: 2