Python – Using Docker via Windows console: includes invalid characters $PWD for a local volume name

dockerpythonwindows

I try to run a Python program with Docker via the Windows console (Windows 10).

I had made the Windows console be capable of Docker Hello, World!.

But when I run:

 docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp python:2 python test.py

I get the error:

docker: Error response from daemon: create $PWD: volume name invalid:
"$PWD" includes invalid characters for a local volume name, only
"[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed.

See 'docker run –help'.

While running the same code via Docker Quickstart Terminal, it runs well.

I tried to, but I can't solve it. How can I do it?

Best Answer

I think, the substitution of Linux command $(pwd) in Windows is "%cd%".

So, try out following command which might help you.

docker run -it --rm --name my-running-script -v "%cd%":/usr/src/myapp -w /usr/src/myapp python:2 python test.py
Related Topic