I am working to containerize a program. The program requires a configuration file and directories for its operation, which are passed as command line arguments, e.g. something like this:

$ myprog -c /path/to/config.conf -i /directory/with/input_files -o /directory/with/output_files

I know that I will need mount docker volumes to the containerized version of this program so that it can access the config file and directories. But, I would like to maintain the command-line interface unchanged (as far as possible) to hide the complexity of using docker volumes, etc. from users. How do I do this?

Will I need to create a wrapper script that maps the values of the command-line arguments (-c, -i, -o) to mount the corresponding paths as docker volumes? If so, what is the best practice for packaging it (i.e. to distribute the script with the container) and making this work cross-platform (i.e. so that it runs on Windows, MacOS, Linux)?

1 Answer 1


I would suggest the following approach for the files within your docker-compose.yml:

    - ./config:/path/to
    - ./input:/directory/with/input_files
    - ./output:/directory/with/output_files

Do note that I mount the entire folder in this example, despite you only mentioning one config file. This is on purpose - reasons for that are well explained within this video. Resources on how to define docker-compose.yml in full can be found here. Your final approach could look something like this:

  1. Push Dockerfile to registry of your choice
  2. Provide user the docker-compose.yml for example via Git
  3. User creates folder with the necessary sub-directories (config, input and output in this example)
  4. User supplies valid config file in config folder
  5. User executes docker-compose up -d
  6. Success :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.