为什么 docker 个实例可以在 windows 和 linux 机器上 运行 而不需要 VM?

why docker instances can run on both windows and linux machine without the need of VM?

我是 docker 的新手。我知道 Docker 和 VM 之间的主要区别是,容器共享主机的操作系统,而 VM 需要单独的操作系统。

但我看到一些图像可以生成可以在 Windows 和 Linux 机器上 运行ning 的容器,而不需要 VM。但是它是如何工作的呢?假设我在我的机器上使用 windows 操作系统和 运行 一个 Linux 容器,windows OS 如何提供 Linux 的容器中 运行ning 应用程序的内核?

顺便说一句,如果 windows 可以 运行 linux 容器,那么这是否意味着我们作为用户可以使用以前专用于 linux 的所有工具只要软件公司为该工具创建图像?

当 运行在 Windows 上运行时,Docker 的最新版本使用 WSL2,which uses a lightweight virtual machine:

WSL 2 uses the latest and greatest in virtualization technology to run a Linux kernel inside of a lightweight utility virtual machine (VM).

因此,当使用 docker 时,您实际上 运行 在 VM 中安装了一个完整的 Linux 内核,尽管体验是透明的。当您 运行 一个容器时,它实际上是该 VM 中的一个容器。