TL;博士:
100 Can Windows containers run on Linux?
A: No. They cannot.
容器正在使用底层操作系统资源和驱动程序,因此Windows容器只能在Windows上运行,Linux容器只能在Linux上运行.
100 But what about Docker for Windows? Or other VM-based solutions?
A: Docker for Windows允许您在102上模拟运行101个容器,但在后台创建了一个Linux虚拟机,所以仍然是Linux containers are running on Linux, and Windows containers are running on Windows.
奖励:阅读this very nice article篇关于在Windows上运行Linux docker容器的文章.
100 So, what should I do with a .NET Framework 462 application, if I would like to run in a container?
A:视情况而定.以下几点建议:
如果可能的话,请转到.净核心.自从NET Core为的大多数主要功能提供了支持.NET框架,以及.NET Framework 4.8 will be the last version of .NET framework
如果无法迁移到.NET Core——正如@Sebastian所提到的——你可以将你的库转换为.NET Standard,并且有两个版本的应用程序——一个在上.NET Framework 4.6.2和一对一.净核心——这并不总是显而易见的.VisualStudio很好地支持它(具有多目标),但某些依赖项可能需要额外小心.
(不太推荐)在某些情况下,可以运行Windows容器.Windows容器正变得越来越成熟,在Kubernetes等平台上有更好的支持.而是为了能跑.NET框架代码,您仍然需要在"服务器核心"的基本映像上运行,该映像约占1.4GB.在同样罕见的情况下,您可以将代码迁移到.NET内核,但仍在Windows Nano server上运行,映像大小为95MB.
Leaving also the old updates for history
100
如果您正在使用Docker for Windows,现在可以同时运行Windows和Linux容器simultaneously:100
Bonus:与这个问题没有直接关系,但您现在不仅可以运行Linux容器本身,还可以运行Kubernetes:100之类的orchestrator
100
最初的答案大体上是正确的,BUT几个月前,docker增加了experimental feature LCOW(official GitHub repository).
从this post开始:
Docker for Windows不是已经运行Linux容器了吗?没错.
The setup for running Linux containers with LCOW is a lot simpler than
the previous architecture其中Hyper-V Linux虚拟机运行Linux Docker
因为只有一个Docker守护程序,而且现在这个守护程序
100
正如@PanagiotisKanavos在 comments 中提到的,容器不是用于虚拟化的,它们是are using the resources of the host machine.因此,目前Windows容器无法在Linux机器上"按原样"运行.
But——你可以使用虚拟机来实现——因为它可以在Windows上运行.您可以在Linux主机上安装windows VM,这将允许运行windows容器.
有了它,IMHO在production环境中以这种方式运行它将不是最好的主意.
此外,this answer还提供了更多细节.