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!
2
Answers
This url has redirect with 302. You have to use -L parameter with curl to follow the link.
curl is downloading the html redirect page.
You can tell curl to follow the redirects using
-L
option.