使用 Docker for windows 将 windows 驱动器卷挂载到 Linux 容器中

Using Docker for windows to volume-mount a windows drive into a Linux container

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

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

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

docker run -d --name qbittorrent -v "/f/Fetched Media/Unsorted":/downloads -v "/f/Fetched Media/Blackhole":/blackhole linuxserver/qbittorrent

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

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

*不过,首先,请确保您已在 GUI 的 Docker 桌面设置区域中共享那些 Windows 文件夹。

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

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

docker run -d --name qbittorrent -v "/f/Fetched Media/Unsorted:/downloads" -v "/f/Fetched Media/Blackhole:/blackhole" linuxserver/qbittorrent

否则,J. Scott Elblein 的回答非常有效!