如何在 Docker 中为 Windows 设置共享驱动器?

How to set the shared drives in Docker for Windows?

如何在 Docker 中为 Windows 设置共享驱动器?我使用的是最新版本 18.Stable 和 Edge。我的设置屏幕如下所示。它缺少一些选项,如第二张图片中显示的共享驱动器、高级和网络。为什么我缺少这些选项?

我的设置:

来自网站的屏幕截图:

您似乎 运行 Docker for Windows 使用“Windows 容器”。如果切换到“Linux 容器”,您将看到“共享驱动器”选项。 Take a look this video.

According Docker documentation: 未实现 Windows 容器的共享驱动器。

Volume mounting requires shared drives for Linux containers (not for Windows containers).

更新: 自 2018 年以来,桌面版 Docker 使用 新的 UI。我录制了一个显示 how to solve this problem.

的新视频

更新: 如果您使用 WSL2,您将遇到同样的问题。 Take a look this video.

在新的 UI 中,它们位于资源下

到此结束,因为我的 docker 设置中缺少“共享驱动器”。如果你也错过了它,但是 docker 是为 linux 容器设置的,那是因为 WSL 2.

因为如果您在 WSL 2 上使用 Docker,则没有这样的选项,但是您可以使用 docker run -v c:\...\your-folder:/mount ... 直接从文件系统附加卷,而无需在 docker 设置中指定。