[英]How to access current directory with Boot2Docker and Docker?
I run Docker container 我运行Docker容器
docker run -it python
from which I can't see my local files. 从那里我看不到我的本地文件。
How can I mount my current (host) directory (from which I run docker
) as current directory inside the docker container? 如何将当前(主机)目录(从中运行docker
)挂载为docker容器中的当前目录? So that I can 这样我就可以
import file
inside the container and it will find the local file.py
. 在容器内,它将找到本地file.py
I could only find complicated solutions, where I have to explicitly mount the host directory, which seems to require absolute paths, where I'd like to type something dynamic like .
我只能找到复杂的解决方案,在这里我必须显式安装主机目录,这似乎需要绝对路径,在这里我要输入诸如动态的东西.
as path (doesn't work). 作为路径(无效)。
You mean like: 您的意思是:
docker run -v $(pwd)/:/codedir -it python
? ?
You can't use relative paths like "." 您不能使用“。”之类的相对路径。 in volume commands. 在音量命令中。 If it annoys you that much, try using Docker Compose, which does allow relative paths. 如果这让您非常烦恼,请尝试使用允许相对路径的Docker Compose。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.