You need to be sure to save your file into the mounted directory. Right now, it looks like your file is being saved as a sibling to your program which is right outside of the mounted directory.
Since you mount with:
docker run -v /home/user/tmp/:/repo/dir image dir/file1 dir/file2
/repo/dir is the only folder you will see changes to. But if you are saving files to /repo, they will get saved there, but not seen on the host system after running.
Consider how you open your output file:
std::string filename (“result.md”); // in the actual code this name is not hard-coded and depends on intput, but it will not include / chars
output_file << some_data << etc << std::endl;
Since you set the output file to “result.md” with no path, it is going to be opened as a sibling to the program.
If you were to run
docker run -it --rm --entrypoint=/bin/bash image
which would open an interactive shell using your image and then run ./program some-file.text some-other-file.txt and then ran ls you would see the output file result.md as a sibling to program. That is outside of your mountpoint, which is why you don’t see it on your host machine.
Consider this program. This program will take an input file and an output location. It will read in each line of the infile and wrap it in
. /some is the repository directory. /some/res/ is the folder that will be mounted to /repo/res/.
I provide 2 arguments to my program through docker run, the infile and outfile both of which are relative to /repo which is the working directory.
My program then saves to the outfile location which is within the mountpoint (/repo/res/). After docker run finishes, /some/res/out.txt is populated.