Windows上的Docker和Linux容器,带有或不带有Hyper-V虚拟机

Containers are lovely, in case you haven't heard. They are a nice and clean way to get a reliable and guaranteed deployment, no matter the host system.

容器很可爱,以防您听不到。 无论主机系统如何,它们都是一种获得可靠且有保证的部署的好方法。

If I want to run my my ASP.NET Core application, I can just type "docker run -p 5000:80 shanselman/demos" at the command line, and it'll start up! I don't have any concerns that it won't run. It'll run, and run well.

如果要运行我的ASP.NET Core应用程序,只需在命令行输入“ docker run -p 5000:80 shanselman / demos”,它就会启动! 我不担心它不会运行。 它会运行,并且运行良好。

Some containers naysayers say , sure, we could do the same thing with Virtual Machines, but even today, a VHD (virtual hard drive) is rather an unruly thing and includes a ton of overhead that a container doesn't have. Containers are happening and you should be looking hard at them for your deployments.

反对者肯定地说,有些容器可以用虚拟机来做同样的事情,但是即使到了今天,VHD(虚拟硬盘驱动器)仍然是不守规矩的事情,并且包含了许多容器没有的开销。 容器正在发生,您应该认真考虑它们的部署。

Windows上的Docker和Linux容器,带有或不带有Hyper-V虚拟机

Historically on Windows, however, Linux Containers run inside a Hyper-V virtual machine. This can be a good thing or a bad thing, depending on what your goals are. Running Containers inside a VM gives you significant isolation with some overhead. This is nice for Servers but less so for my laptop. Docker for Windows hides the VM for the most part, but it's there. Your Container runs inside a Linux VM that runs within Hyper-V on Windows proper.

但是,从历史上讲,Windows容器在Hyper-V虚拟机中运行。 根据您的目标,这可能是好事,也可能是坏事。 在VM内运行容器可以为您带来显着的隔离,并带来一些开销。 这对服务器来说不错,但对我的笔记本电脑则不太好。 适用于Windows的Docker在很大程度上隐藏了VM,但它在那里。 您的容器在运行于Windows上的Hyper-VLinux VM内运行。

Windows上的Docker和Linux容器,带有或不带有Hyper-V虚拟机

With the latest version of Windows 10 (or 10 Server) and the beta of Docker for Windows, there's native Linux Container support on Windows. That means there's no Virtual Machine or Hyper-V involved (unless you want), so Linux Containers run on Windows itself using Windows 10's built in container support.

借助最新版本的Windows 10(或10服务器)和Docker Beta for Windows,Windows上具有本机Linux容器支持。 这意味着不涉及虚拟机或Hyper-V(除非您愿意),因此Linux容器使用Windows 10的内置容器支持在Windows本身上运行。

For now you have to switch "modes" between Hyper V and native Containers, and you can't (yet) run Linux and Windows Containers side by side. The word on the street is that this is just a point in time thing, and that Docker will at some point support running Linux and Windows Containers in parallel. That's pretty sweet because it opens up all kinds of cool hybrid scenarios. I could run a Windows Server container with an .NET Framework ASP.NET app that talks to a Linux Container running Redis or Postgres. I could then put them all up into Kubernetes in Azure, for example.

现在,您必须在Hyper V和本机容器之间切换“模式”,并且您(并不能)同时运行Linux和Windows容器。 俗话说,这只是一个时间点,而Docker将在某个时候支持并行运行Linux和Windows容器。 这非常好,因为它打开了各种很酷的混合方案。 我可以使用与.NET Framework ASP.NET应用程序运行Windows Server容器,该应用程序与运行Redis或PostgresLinux容器通信。 然后,我可以将它们全部放入Azure中的Kubernetes中。

Once I've turned Linux Containers on Windows on within Docker, everything just works and has one less moving part.

一旦我在Docker中启用了Windows上Linux容器,一切都将正常运行,并且移动的部分将减少。

Windows上的Docker和Linux容器,带有或不带有Hyper-V虚拟机

I can easily and quickly run busybox or real Ubuntu (although Windows 10 already supports Ubuntu natively with WSL):

我可以轻松快速地运行busybox或真正的Ubuntu(尽管Windows 10已经通过WSL原生支持Ubuntu ):

Windows上的Docker和Linux容器,带有或不带有Hyper-V虚拟机

More useful even is to run the Azure Command Line with no install! Just "docker run -it microsoft/azure-cli" and it's running in a Linux Container.

甚至更有用的是无需安装即可运行Azure命令行! 只需“ docker run -it microsoft / azure-cli”,它就在Linux容器中运行。

Windows上的Docker和Linux容器,带有或不带有Hyper-V虚拟机

I can even run nyancat! (Thanks Thomas!)

我什至可以跑nyancat! (谢谢托马斯!)

docker run -it supertest2014/nyan

码头工人运行-it supertest2014 / nyan

Windows上的Docker和Linux容器,带有或不带有Hyper-V虚拟机

Speculating - I look forward to the day I can run "minikube start --vm-driver="windows" (or something) and easily set up a Kubernetes development system locally using Windows native Linux Container support rather than using Hyper-V Virtual Machines, if I choose to.

推测-我期待有一天可以运行“ minikube start --vm-driver =“ windows”(或类似工具),并使用Windows本机Linux容器支持而不是使用Hyper-V虚拟机轻松地在本地设置Kubernetes开发系统,如果我选择的话。



Sponsor: Why miss out on version controlling your database? It’s easier than you think because SQL Source Control connects your database to the same version control tools you use for applications. Find out how.

发起人:为什么错过控制数据库的版本? 它比您想象的要容易,因为SQL Source Control将您的数据库连接到用于应用程序的相同版本控制工具。 了解如何。

关于斯科特 (About Scott)

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

斯科特·汉塞尔曼(Scott Hanselman)是前教授,前金融首席架构师,现在是演讲者,顾问,父亲,糖尿病患者和Microsoft员工。 他是一位失败的单口相声漫画家,一个玉米种植者和一本书的作者。

Windows上的Docker和Linux容器,带有或不带有Hyper-V虚拟机
Windows上的Docker和Linux容器,带有或不带有Hyper-V虚拟机
Windows上的Docker和Linux容器,带有或不带有Hyper-V虚拟机
About   关于 Newsletter 时事通讯
Hosting By 主持人
Windows上的Docker和Linux容器,带有或不带有Hyper-V虚拟机

翻译自: https://www.hanselman.com/blog/docker-and-linux-containers-on-windows-with-or-without-hyperv-virtual-machines