0

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

4
  • Why not just run docker run python:3.7 print.py ? Commented Feb 5, 2022 at 8:26
  • If you have a working host Python installation, why introduce Docker into it? Can you build a self-contained image with your application code built in, instead of using a bind mount? (This initially sounds like a Windows shell problem to me.) Commented Feb 5, 2022 at 12:17
  • @MarkSetchell got this: docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "print.py": executable file not found in $PATH: unknown. Commented Feb 5, 2022 at 19:59
  • @DavidMaze Just for training purposes Commented Feb 5, 2022 at 20:00

1 Answer 1

1

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 ...

Sign up to request clarification or add additional context in comments.

1 Comment

It works: $ MSYS_NO_PATHCONV=1 docker run --volume $(pwd):/home/${USER} python:3.7 python /home/${USER}/print.py Thanks!

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.