I\'m writting a C++ program that is run as follows:
./program data_file config_file
And I want to use docker with it. I\'ve written the fol
You can use volume mechanism for mount a host directory to the container.
Create file1.txt
and file2.txt
files in some directory in the host machine. For example we are creating files in the /var/dir1/
directory.
Your working dir in the docker container is /program
.
So when you are running docker you should mount this host directory to container using -v flag
docker run -v /var/dir1/:/program test file1.txt file2.txt
Oh, I know why we have problem.
When I am mounting the host directory to working dir I am actually deleting all created files inside container from it working dir including the ./program
binary file. So the docker run
command is failed.
therefore we not must mount working directory. We can mount subdirectory of working directory for example.
docker run -v /var/dir1/:/program/dir test dir/file1.txt dir/file2.txt
It works for me!