I am trying to deploy and run the java application in kubernetes POD for which I am getting below error. But when I run it as a docker container it is running fine.
Here is the Dockerfile -
FROM openjdk:8-jre-alpine
ENV artifact mysessionmanager-1.0.0-SNAPSHOT.jar
WORKDIR /root/apps
COPY . /root/apps
EXPOSE 8080
ENTRYPOINT ["sh", "-c"]
CMD ["java -jar ${artifact}"]
docker build -t mysessionmanager .
docker tag mysessionmanager xxxx/mysessionmanager:v1
docker push xxxx/mysessionmanager
kubectl run mysessionmanager --image=xxxx/mysessionmanager:v1 --port=8080
kubectl expose deployment --type=NodePort --port=80 --target-port=8080 --name=mysessionmanager
kubectl get deployments
showing my deployment Available status as 0
kubectl get pods
showing my POD's status as CrashLoopBackOff
kubectl get logs mysessionmanager-5654545f8-mvt5x
shows nothing
kubectl describe pod mysessionmanager-5654545f8-mvt5x
Reason: CrashLoopBackOff
Last State: Terminated
Reason: ContainerCannotRun
Message: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"java -jar mysessionmanager-1.0.0-SNAPSHOT.jar\": executable file not found in $PATH": unknown
But when I directly run the docker image using below command it works fine.
docker run -it mysessionmanager
Appreciate any help. Thanks
there is no need top use BOTH cmd and entrypoint commands.
in my projects I create a small bash script that the java command is written inside.
that small script is running in my entry-point without any cmd configured.