Reputation: 13
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'
Upvotes: 1
Views: 1479
Reputation: 9481
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
Be aware however that -v
option is known to be extremely slow.
Upvotes: 5