适用于WSL 2的Docker桌面更紧密地集成了Windows 10和Linux

Being able to seamlessly run Linux on Windows is making a bunch of common development tasks easier. When you're running WSL2 (Windows Subsystem for Linux 2) in a version of Windows 10 greater than build 18945, a BUNCH of useful and interesting scenarios light up and stuff just works.

能够在Windows上无缝运行Linux使得许多常见的开发任务变得更加容易。 当您在版本大于18945的Windows 10版本中运行WSL2(用于Linux 2的Windows子系统)时,大量有用和有趣的场景都会亮起,并且一切正常。

Docker for Windows (download the Docker Desktop for WSL 2 Tech preview here) is great, but it has historically worked on Windows by creating a Hyper-V virtual machine called Moby that is visible within the Hyper-V client. It's a utility VM, but it's one you're aware of.

适用于Windows的Docker (在此处下载用于WSL 2 Tech的Docker桌面预览)非常棒,但是从历史上讲,它已在Windows上通过创建称为Moby的Hyper-V虚拟机在Hyper-V客户端中可见的虚拟机工作。 这是一个实用程序VM,但是您知道的。

Docker for Windows using WSL2

However, if WSL2 runs a real Linux kernel in Windows 10 and it's managing a virtual machine platform underneath (and not visible to) Hyper-V client tools, then why not just let WSL2 handle containers for us?

但是,如果WSL2在Windows 10中运行了一个真正Linux内核,并且正在管理Hyper-V客户端工具(对Hyper-V客户端工具不可见)下的虚拟机平台,那么为什么不让WSL2为我们处理容器呢?

That's exactly what the Docker Desklop WSL 2 Tech Preview aims to do. And just like WSL 2, it's fast.

这正是Docker Desklop WSL 2 Tech Preview的目标。 就像WSL 2一样,速度也很快。

...the time required to start a Docker daemon after a cold start is significantly faster. It takes less than 2 seconds to start the Docker daemon when compared to tens of seconds in the current version of Docker Desktop.

...冷启动后启动Docker守护程序所需的时间明显更快。 与当前版本的Docker Desktop中的数十秒相比,启动Docker守护程序所需的时间不到2秒。

Once you've got a Linux (Ubuntu or the like) set up in WSL 2, you can right click on Docker Deskop and click "WSL 2 Tech Preview." This is a goofy and not-super-intuitive UI for now but it's a moment in time.

在WSL 2中设置完Linux(Ubuntu等)后,您可以右键单击Docker Deskop,然后单击“ WSL 2 Tech Preview”。 目前,这是一个愚蠢且不超级直观的UI,但这只是时间。

Click WSL 2 Tech Preview

Then you just hit Start.

然后,您只需单击开始。

NOTE: If you've already installed Docker within WSL 2 at the command line, stop it and let Docker Desktop manage its lifecycle.

注意:如果您已经在命令行中的WSL 2中安装了Docker,请停止它并让Docker Desktop管理其生命周期。

Here's the beginnings of their UI.

这是他们的UI的开始。

Docker for WSL2

When I drop out to PowerShell/CMD on Windows I can run "docker context ls."

当我退出Windows上的PowerShell / CMD时,我可以运行“ docker context ls”。

C:\Users\Scott\Desktop> docker context ls    
NAME DESCRIPTION DOCKER ENDPOINT
default Current DOCKER_HOST based configuration npipe:./pipe/docker_engine
wsl * Docker daemon hosted in WSL 2 npipe:./pipe/docker_wsl

You can see there's two contexts, and I've run "docker context use wsl" and that's now my default.

您可以看到有两个上下文,并且我已经运行了“ docker context use wsl”,现在这是我的默认设置。

Here is docker images from Ubuntu, and again from Windows (in PowerShell Core). They are the same!

这是来自Ubuntu的docker映像,以及来自Windows(在PowerShell Core中)的docker映像。 他们是一样的!

Docker images in Ubuntu
Docker images from Powershell

Sweet. Here I am using PowerShell Core (which is open source and cross-platform, natch) to manage my builds which are themselves cross-platform and I can run both a docker build or a metal build on both Windows or Linux, all seamlessly on the same box.

甜。 在这里,我使用PowerShell Core(开放源代码和跨平台,natch)来管理自己的跨平台构建,并且我可以在Windows或Linux上同时运行docker构建或金属构建,并且都可以在Windows和Linux上无缝运行同一个盒子。

building docker images

Also note, Simon from Docker points out "We are using a non default dataroot in this mode to avoid corrupting a datastore you use without docker desktop in case something goes wrong. Stopping the docker desktop wsl daemon and restarting the one you installed manually should bring everything back." I noticed this because my "Windows Docker" and my original WSL2 docker had a list of images that I naively expected to be available here, but this is a new context and new dataroot so you may need to fetch images again in this new world if you're have been historically an active docker user.

还要注意,来自Docker的Simon指出: “在这种模式下,我们将使用非默认数据根,以避免损坏在没有docker桌面的情况下使用的数据存储,以防万一出问题。停止docker桌面wsl守护程序并重新启动手动安装的守护程序应该会一切都回来了。” 我注意到了这一点,因为我的“ Windows Docker”和我最初的WSL2 Docker都有一个我天真希望在此处可用的图像列表,但这是一个新的上下文和新的数据根,因此如果在这种情况下,您可能需要再次获取图像您一直以来都是活跃的docker用户。

So far I'm super impressed. Linux on the Windows Desktop feels right. It's Peanut Butter and Chocolate.

到目前为止,我印象深刻。 Windows桌面上Linux感觉不错。 是花生酱和巧克力

Sponsor: Looking for a tool for performance profiling, unit test coverage, and continuous testing that works cross-platform on Windows, macOS, and Linux? Check out the latest JetBrains Rider!

赞助商:是否正在寻找一种可在Windows,macOS和Linux上跨平台运行的性能分析,单元测试覆盖率和连续测试工具? 查看最新的JetBrains骑士!

翻译自: https://www.hanselman.com/blog/docker-desktop-for-wsl-2-integrates-windows-10-and-linux-even-closer

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值