Home > other >  Run python script from Docker
Run python script from Docker

Time:02-06

Trying to run test Python script from Docker using Bash. Win10 OS. I have a file print.py in the directory C:/Py/test

  1. run this $ cd C:/Py/test
  2. run this $ docker run --volume $(pwd):/home/${USER} python:3.7 python /home/${USER}/print.py

Got this error: python: can't open file 'C:/Program Files/Git/home/print.py': [Errno 2] No such file or directory

Why is this file trying to be found in the C:/Program Files/Git/home/ directory instead of C:\Py\test?

$ python 'print.py' is working

enter image description here

CodePudding user response:

Git bash prepended its installation path, try these two methods :

  1. Use: //home/${USER}/print.py

  2. Run with: MSYS_NO_PATHCONV=1 docker run ...

  •  Tags:  
  • Related