0

I'm new in the community and i'm new in docker's world. i have to virtualize a leshan server through docker and I have to do this with the option "--redis" that leshan makes avaible. so I decided to take a dockerfile from docker hub and modify the last "CMD" operation adding the option "--redis". The Build of images is successful but when i try to run the image in a container the error is "Invalid or corrupt jarfile". This problem show up also without the option "--redis" (with the no modify dockerfile). The strange thing is that if I pull the image from dockerhub and run the server build through same dockerfile, it works!

This is the docker file:

FROM linarotechnologies/alpine:edge

RUN apk add --no-cache openjdk8-jre-base ca-certificates shadow curl
runit

RUN mkdir -p /opt/leshan-server-demo && \
    curl -o /opt/leshan-server-demo/leshan-server-demo.jar \
    https://hudson.eclipse.org/leshan/job/leshan/lastSuccessfulBuild/artifact/leshan-server-demo.jar
RUN useradd -r -d /opt/leshan-server-demo -s /sbin/nologin -U leshan

CMD cd /tmp && chpst -u leshan java -jar /opt/leshan-server-demo/leshan-server-demo.jar $LESHAN_ARGS

this is the build:

Sending build context to Docker daemon  7.294MB
Step 1/5 : FROM linarotechnologies/alpine:edge
 ---> 7463224280b0
Step 2/5 : RUN apk add --no-cache openjdk8-jre-base ca-certificates shadow curl runit
 ---> Using cache
 ---> ebe6e6280cdf
Step 3/5 : RUN mkdir -p /opt/leshan-server-demo &&     curl -o /opt/leshan-server-demo/leshan-server-demo.jar         https://hudson.eclipse.org/leshan/job/leshan/lastSuccessfulBuild/artifact/leshan-server-demo.jar
 ---> Using cache
 ---> 52b61160e8c5
Step 4/5 : RUN useradd -r -d /opt/leshan-server-demo -s /sbin/nologin -U leshan
 ---> Using cache
 ---> 53419af60e36
Step 5/5 : CMD cd /tmp && chpst -u leshan java -jar /opt/leshan-server-demo/leshan-server-demo.jar $LESHAN_ARGS#
 ---> Running in 52cb5fc95ffb
Removing intermediate container 52cb5fc95ffb
 ---> 68acab7c306e
Successfully built 68acab7c306e
Successfully tagged leshan-server:latest

And this is the error when i run:

sudo docker run --rm -ti --name leshan-server leshan-server Error: Invalid or corrupt jarfile /opt/leshan-server-demo/leshan-server-demo.jar

Any ideas? Thank you for help!

Shashank V
  • 10,007
  • 2
  • 25
  • 41
  • You can try to clean your build cache and then build the image again. If you once got an invalid jar you still have it cached. – Henry Jun 11 '20 at 08:14
  • i tried but it doesn't work. :( – Antonio Romano Jun 11 '20 at 08:21
  • Is there a chance that the error is right and you simply have a corrupt JAR file? Does that JAR file work properly in other settings? https://stackoverflow.com/questions/7559072/corrupt-jar-file – QA Collective Jun 11 '20 at 22:54

2 Answers2

1
https://hudson.eclipse.org/leshan/job/leshan/lastSuccessfulBuild/artifact/leshan-server-demo.jar

This url has redirect with 302. You have to use -L parameter with curl to follow the link.

librhnylmz
  • 11
  • 1
  • I add the -L parameter but when i run the image show this error: 'Exception in thread "main" java.lang.ExceptionInInitializerError' – Antonio Romano Jun 11 '20 at 09:26
0
~# curl -o test.jar https://hudson.eclipse.org/leshan/job/leshan/lastSuccessfulBuild/artifact/leshan-server-demo.jar

~# cat leshan-server-demo.jar
<html>
<head><title>302 Found</title></head>
<body>
<center><h1>302 Found</h1></center>
<hr><center>nginx</center>
</body>
</html>

curl is downloading the html redirect page.

You can tell curl to follow the redirects using -L option.

/opt/leshan-server-demo # curl -L -o test.jar https://hudson.eclipse.org/leshan/job/leshan/lastSuccessfulBuild/artifact/leshan-server-demo.
jar
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   138  100   138    0     0    316      0 --:--:-- --:--:-- --:--:--   315
100 7618k  100 7618k    0     0   622k      0  0:00:12  0:00:12 --:--:--  481k
/opt/leshan-server-demo #
Shashank V
  • 10,007
  • 2
  • 25
  • 41