Reputation: 12705
I have a program written in C that takes two filenames as arguments, one as input and another as output. I would like to put this command-line program into a docker container for portability and consistency, and to be able to pass files from the host OS as command line arguments when the container is invoked.
That is, I have a program that is typically invoked:
progname inputfile outputfile
and I would like to be able to invoke it as:
docker [options] inputfile outputfile progname
in some order and have inputfile and outputfile refer to files on the host OS.
How can I create a docker container that is able to take filenames on the host OS as arguments?
Upvotes: 1
Views: 65
Reputation: 498
What you want to create is an image, i.e. the template for containers. You then want to mount the host OS volume when creating new containers with docker run
. For that, check this page. What you want to do is:
docker run -itd -v <host_directory>/<filename>:<container_directory>/<filename> <image_name> <container_name> <cmd_or_shell_to_run>
Upvotes: 1