使用 Docker for windows 将 Windows 驱动器卷安装到 Linux 容器中

Yos*_*ALI 7 containers docker linux-containers dockerfile docker-machine

我在 Windows 上使用 Docker,我想在 Linux 容器中找到 Docker 创建的卷的位置?

有没有人能够执行我试图实现的卷安装?

J. *_*ein 12

如果您只是尝试将 Windows 路径挂载到基于 Linux 的容器,这里有一个使用基本docker run命令的示例:

docker run -d --name qbittorrent -v "/f/Fetched Media/Unsorted":/downloads -v "/f/Fetched Media/Blackhole":/blackhole linuxserver/qbittorrent
Run Code Online (Sandbox Code Playgroud)

此示例将 Windows 主机上的f:\Fetched Media\Unsortedf:\Fetched Media\Blackhole文件夹共享到容器,并且在 Linux 容器中,您会在冒号右侧显示的相应 Linux 路径中看到来自这些 Windows 文件夹的文件。

即该f:\Fetched Media\Unsorted文件夹将/downloads位于 Linux 容器中的文件夹中。

*首先,请确保您已在 GUI 的 Docker 桌面设置区域内共享了这些 Windows 文件夹。

WSL(2) 更新:您不需要专门共享 Windows 文件夹路径;仅在不使用 WSL 时才需要。

  • 我在互联网上到处搜索这个。太感谢了。真的很惊讶它没有出现在 Docker 文档中 (3认同)

wil*_*mab 5

我不确定为什么需要这样做,但如果其他人遇到这个问题:我必须将整个卷声明放在双引号中,如下所示

docker run -d --name qbittorrent -v "/f/Fetched Media/Unsorted:/downloads" -v "/f/Fetched Media/Blackhole:/blackhole" linuxserver/qbittorrent
Run Code Online (Sandbox Code Playgroud)

否则,J. Scott Elblein 的回答完美无缺!