1

I am using Docker for windows. I am trying to send a csv file as an input to a python file, as an argument to docker run. The python file accepts a file as an input, which can be seen from the following snippet.

 my_data = genfromtxt(sys.argv[1], delimiter=',') 

The dockerfile looks like following.

#install ubuntu and python
USER changepoint #create user changepoint

WORKDIR /home/changepoint/ # change to directory changepoint
COPY CPDetection.py /home/changepoint/ #copy python file to directory

ENTRYPOINT ["python3.5","CPDetection.py"] # create an entrypoint 
CMD ["foo1.csv"]    #placeholder to accept input file

I am mounting the host folder to a volume in docker, then mentioning the input file as an argument, but i am getting the error

OSError: file.csv not found.

The command i am using to send the input is following (in powershell)

docker run -v C:/folder/:\home\changepoint\ -t changepoint npdata.csv

C:/folder contains the npdata.csv file, and i am mounting it to /home/changepoint, but i am not sure if the mount is successful, given that i am getting the error that file could not be found.

How can i resolve this?

sid0972
  • 141
  • 1
  • 4
  • 13
  • Try this: docker run -v C:/folder:/home/changepoint -t changepoint npdata.csv – Jaur Jan 28 '19 at 14:18
  • All of your slashes in the `-v` option point the wrong way; but if you do this successfully, you’ll also overwrite the script you’re trying to run. Consider mounting the data directory somewhere else. If interacting with local files is the most important thing you’re doing, also consider not using Docker but instead something like a Python virtual environment, so that you don’t have a separate filesystem layer to manage mappings and permissions for. – David Maze Jan 28 '19 at 14:31
  • I tried this, i got the error `OCI runtime create failed, executable file not found in $PATH`, i [googled](https://stackoverflow.com/questions/50309605/reading-input-files-with-docker?noredirect=1&lq=1), and created a subdirectory, now i am getting error `permission denied` – sid0972 Jan 28 '19 at 14:32
  • @DavidMaze What should the arrows look like? And no interaction with files is not the most important thing. I did create a subdirectory inside the /home/changepoint but that does not seem to be working as well. – sid0972 Jan 28 '19 at 14:40
  • On the right-hand side the colon (in Linux container space) it needs to be forward slashes, `...:/home/changepoint`. If it’s backslashes it will probably just create an oddly-named directory. – David Maze Jan 28 '19 at 14:41
  • @DavidMaze i tried with forward slashes, now i am getting `python3.5: can't open file 'CPDetection.py': [Errno 2] No such file or directory`. It cannot find the python file. – sid0972 Jan 28 '19 at 14:44

0 Answers0