Corrupt jar in minikube

12/13/2018

I try to run my spring-boot application in the minikube from local docker image.

$ eval $(minikube docker-env)
$ docker build -t built_name .
$ kubectl run serviceName --image=image_name:latest --image-pull-policy=Never

My Dockerfile:

FROM registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift

ARG jarFinal

ENV LC_ALL=en_US.utf8

COPY --chown=185:0 ${jarFinal} app.jar
COPY --chown=185:0 entrypoint.sh /entrypoint.sh
COPY --chown=185:0 version.json /version.json

RUN chmod +x /entrypoint.sh

EXPOSE 8080

ENTRYPOINT [ "/entrypoint.sh" ]

CMD java -Xmx256m -jar app.jar

After this i see in the kubernets pods logs:

Error: Invalid or corrupt jarfile app.jar

But when i tried to start this jar locally, with 'RUN java -Xmx256m -jar app.jar', its starting successfully. What i do wrong? Thanks.

UPD: I tried to start image with local docker (docker run) and all ok, then i tried the same in minikube with minikube docker (minikube ssh -> docker run), and I get the same error 'corrupt jar'...

-- Максим
docker
java
kubernetes
minikube
spring

1 Answer

12/14/2018

Problem solved!

$ docker save myImage | (eval $(minikube docker-env) && docker load)
$ kubectl ssh 'docker tag myImage myTag'
$ kubectl run ServiceName --image=myTag --image-pull-policy=Never

'docker build' crashed my image..

-- Максим
Source: StackOverflow