copy file from container to the host before the container dies
I am pretty novice to the docker container. I am trying to build an image which is running a jar file. I want to pass the output file to the host for further processing but the container exits as soon as it finish the command.
1- what is the best practices for this problem?
2- is there any way to pass the file name dynamically instead of hard coding in the docker file.
here is my Dockerfile:
FROM mybase:latest VOLUME /root/:/var/myVol/ EXPOSE 8080 ADD mydir/test.jar /tmp/test.jar CMD bash -c 'java -jar /tmp/test.jar > /var/myVol/output.json'
One Solution collect form web for “copy file from container to the host before the container dies”
You can just mount output file as a volume using -v option. Your program will write directly to the output file on the host without any need to copy anything anywhere