Docker: How to mount current directory in Windows

2020-07-30 05:39发布

I am using docker toolbox v17.03 in Windows 10 Home. I am playing with flask app from python slim. I tried to mount the current directory to app and tried ${PWD} and %cd% like below.

docker container run -it  -p 5000:5000 -e FLASK_APP=app.py --rm -e FLASK_DEBUG=1 -v %cd%:/app web1

==> Got the error saying invalid characters

docker container run -it  -p 5000:5000 -e FLASK_APP=app.py --rm -e FLASK_DEBUG=1 -v ${PWD}:/app web1

==> Neither error nor working

标签: docker
1条回答
放荡不羁爱自由
2楼-- · 2020-07-30 06:03

The second form ${PWD} would be working in a Powershell session.

If it still says "invalid characters", that means:

  • the %cd% is not resolved as an absolute path
  • it includes characters that are not in [a-zA-Z0-9][a-zA-Z0-9_.-], making it inelligible for a volume name.

Double-check what %cd% returns, and if there is any special non-ascii character in it (or spaces)

查看更多
登录 后发表回答