With the upgrade of the docker, adding jar to the container with the absolute path no longer works. How to make, that at restart of the container the new jar was picked up?
I did a new jar and restarted the container, now I can not do this because it’s impossible to specify the absolute path to the new jar in Dockerfile?
Here is my Dockerfile that worked before updating to the new version of the docker. From him I created a image without any problems.
FROM java:8
VOLUME /tmp
EXPOSE 8888
ADD /home/jdev/docker-storage/jenkins/workspace/CA/build/libs/ca.jar /app.jar
RUN bash -c 'touch /app.jar'
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
Now I can not create an image, because I need to specify a relative path. And after restart a new image is not copied to the Docker-container.
ADD has always required an relative path; and it will try to unpack archive files, which you probably don’t want here. Copy the artifact to the directory the Dockerfile is in and COPY with a relative path.
There are a couple of other things in the Dockerfile that are unnecessary, will have odd side effects, or will make your container harder to debug. I’d write something a little more like:
FROM openjdk:8
COPY ca.jar /app.jar
CMD ["java", "-Djava.security.egd=file:/dev/urandom","-jar","/app.jar"]
If it’s still not working, two good things to try are looking at the output of the container (don’t start it with docker run -d if it exits immediately), and starting it with a shell (docker run --rm -it image name /bin/sh) and looking around.
Thanks for the answer. I understand what you mean. I do not understand what happens with the container when the restart command is called. Where does the docker service know where the docker file is located?
this is just a build time process, you copy the jar from the absolute folder to the current folder, then the
dockerfile ADD command uses the instance in the local folder and puts it whereever u want in the image.
Thank you, I understood this. I do not understand where the docker-service knows where to look for the jar file when it makes container restart. After all, we point the way only when we create an image.
use -v on the docker run, to map a local folder to a container folder
for example (make the source folder read only too)
-v .:/foo:ro
put the jar file in the current directory, and then in the CMD in the dockerfile, copy the jar to the place inside the container u want it. then start the command that uses the jar file.
i believe when u do docker start (actually is a restart), then the container will do the same CMD process.
least it used to.
i have a 50 line script that runs when my container starts (or restarts)
it unbundles a big directory tree (it would make the container >1.5gb in size if packaged with the container)
then checks other folders to copy in supporting jar files and reqired license files, then determines which command to execute based on the parms passed. so the one tiny container can be any of 10 different personalities.
the software it runs is in the zip/gz… the rest of the image is personality agnostic.