by manigandham · 6y ago · 0 comments
WSL2 is a Hyper-V virtual machine that runs actual Linux kernel/distros with some special integrations to allow accessing the filesystem, terminal, docker, and now the GUI.
It's no different than running a Linux VM yourself, but it's installed with a few clicks from the Windows Store and has much better tooling. It's fantastic for building software for Linux while being on Windows. MS has already spent 5 years making the cross-platform .NET Core framework which now runs more on Linux than anywhere else, even in Azure. If you want to build on Linux itself then just boot into Linux, but this is great for Windows becoming a central platform for development, regardless of the final destination for the work.
A similar strategy is used for Windows Sandbox and Defender Application Guard (which run Windows in a proto VM so applications like web browsers can’t access the rest of the system). Interestingly, graphics acceleration also works completely like native (at least to my fairly untrained eye), without assigning a discrete GPU. I think this also happens in WSL2.
edit: seems Docker just chose to disable it because they thought it made memory usage unpredictable: https://github.com/docker/for-win/issues/521
http://lxr.linux.no/#linux+v2.6.34.1/drivers/virtio/virtio_b...
At my day job, my company hasn't yet released the version of Windows that provides WSL2 (IIRC Microsoft released that in June, and my company takes ~12 months to validate and push out new versions of Windows). Many developers have tried to get away with using Docker for Desktop on Windows, which requires the direct use of Hyper-V unless your version of Windows supports WSL2, in which case Docker for Desktop will use that instead of Hyper-V.
Our problem is we have some legacy non-Dockerized apps that require the use of vagrant and VirtualBox (we've failed trying to use vagrant and Hyper-V due to lack of boxes), and VirtualBox is 100% incompatible with Hyper-V. VirtualBox has long "supposedly" been able to function alongside/with Hyper-V, but we have not had a single employee encounter success, out of at least a dozen who have tried. To the point where just disabling Hyper-V from Windows' Optional Features isn't enough to get VirtualBox to work again; it took some searching to discover that you additionally have to prevent the virtualisation stack from even being loaded at boot by running "bcdedit /set hypervisorlaunchtype off" as Administrator.
All we want is Docker to run natively on desktop; and yet, we also need to run VirtualBox VM's side-by-side. Because of work-from-home, some employees are "getting away" with running work-related stacks on their personal macOS or Linux machines, which of course have no such limitations. You can run Docker for Desktop and VirtualBox side-by-side on macOS with zero compatibility problems (and you can use NFS for mounts too instead of the buggy and slow-ass vboxfs or cifs/samba). Proving that Windows is, once again, the outsider and shit operating system that can't even do virtualisation properly (seriously, the "exclusive use of virtualisation" that Hyper-V requires is a fucking joke). We have to run vagrant on each developer's machine for the sole purpose of running a Docker daemon within it, or use shared hosting for a hundred developers on a single VM with only a dozen CPU cores, backed by slow network storage instead of SSDs, because that's what a company with multi-million dollar revenues, and thousands of employees, is willing to provide.
End of rant. I did have a question initially, which is this: does installing and using WSL2 break other virtualisation layers (VirtualBox and friends) in the same way that enabling Hyper-V to use Docker for Desktop broke such software prior to WSL2 support?
VirtualBox is a type-2 hypervisor running on the guest/Windows OS but can't access the CPU extensions since Hyper-V has already acquired them. Running Linux containers on Windows (using Docker or otherwise) always involved Hyper-V, just with different hosts from LinuxKit to WSL2. Docker on Mac OS uses hyperkit which seems to also be a type-2 hypervisor which doesn't conflict with VirtualBox (and in fact the docs state that Docker on MacOS uses VirtualBox drivers to create VMs).
VirtualBox 6.0 is supposed to detect and use the Hyper-V API as well as support nested virtualization but its still experimental. Also I believe you can run 32-bit VirtualBox while Hyper-V is enabled, have you tried that?
I think you're in a tough position and the best solution is probably to make the business case in either upgrading away from Vagrant/VB to Docker or getting some proper standalone Vagrant servers to develop with.
So even WSL2 will not help us, unless we can migrate all VirtualBox boxes to Docker or native Hyper-V. Sigh. Fuck companies who produce software purely for Linux servers, who force their developers to work on Windows machines because of ActiveDirectory, and their relationship with kissing Dell's ass for hardware I could piece together from a garbage dump.
This information probably doesn't help you much if you're tied to VirtualBox though.