This is just a very short post. I just wondered if it is possible to share host's directory among containers and run a jar in the shared directory and save its output to the same directory. So I tested it.
Prepare Jar File to Run
Move a jar file for the test. The jar sends HTTP Get request to Isilon Storage and returns its output as a new file in the same directory.
[root@sunny ~]# mv test_20170804.jar container_volume/
[root@sunny ~]# ls container_volume/
test_20170804.jar
Run 3 Containers and Exectute Jar Respectively
[root@sunny ~]# docker run -it --name jar_test_1 -d -v /root/container_volume:/home openjd
k java -jar /home/test_20170804.jar
09f49384e9af436c560899239a58a30b0ad856680bccab6c9df3ba5db33c2f77
[root@sunny ~]# docker run -it --name jar_test_2 -d -v /root/container_volume:/home openjd
k java -jar /home/test_20170804.jar
92782e7ec1434623b9f61548e648351b3e16f07aacc79b15d10e41348878d96b
[root@sunny ~]# docker run -it --name jar_test_3 -d -v /root/container_volume:/home openjd
k java -jar /home/test_20170804.jar
cea729fab4f9f6748a1965f66ec15f3f954fbfe2883c0d1b68c69325c88d3074
Confirm Outputs from Containers Are Saved Properly
[root@sunny ~]# ls ./container_volume/
jar_20170804_030734.txt
jar_20170804_030743.txt
jar_20170804_030754.txt
test_20170804.jar
That's it! It worked as expected.