Docker容器不与主机绑定

时间:2017-07-19 06:58:00

标签: python docker command-line-interface dockerfile docker-toolbox

我正在使用docker工具箱。我的Windows主机上有一个python脚本“prog1.py”,位于“D:\ Werk \ Code \ Python”。这是我的Dockerfile。

FROM python:3
ADD . /usr/src/app
WORKDIR /usr/src/app
CMD [ "python", "prog1.py"]

这是我CLI的剪辑:

D:\Werk\Code\Python> docker build -t python1 .
Sending build context to Docker daemon  64.51kB
Step 1/4 : FROM python:3
 ---> 955d0c3b1bb2
Step 2/4 : ADD . /usr/src/app
 ---> 6fc5184bcfea
Removing intermediate container 89252e9fc17d
Step 3/4 : WORKDIR /usr/src/app
 ---> 6aa9f12ad078
Removing intermediate container b042591d2069
Step 4/4 : CMD python prog1.py
 ---> Running in 8406f3c9fb35
 ---> ecf8ba2e9e0f
Removing intermediate container 8406f3c9fb35
Successfully built ecf8ba2e9e0f
Successfully tagged python1:latest
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.
PS D:\Werk\Code\Python> docker run -it python1
<Expected output of the script>
PS D:\Werk\Code\Python> docker run -it -v /d/Werk/Code/Python:/usr/src/app python1
python: can't open file 'prog1.py': [Errno 2] No such file or directory

当我在没有绑定的情况下运行图像时,它可以工作,但是当我使用绑定指令运行它时,它会显示Erno 2。

我做错了什么?

0 个答案:

没有答案