I’ve been looking forward to WSL 2 for a while now. If you don’t know what WSL is, it stands for Windows Subsystem for Linux. It allows you to run a Linux environment on Windows, and you can read more here: https://docs.microsoft.com/en-us/windows/wsl/about
I remember trying to setup my own development environment back in college. I needed
those weren’t easy to come by on Windows if you were just starting out and nobody taught you about the toolchain. I remember it being a real pain trying to figure out Cygwin or MinGW, trying to decide between the two, and then opting to just install Ubuntu in a VM.
Anyways, today we have WSL 2, which runs your Linux distributions in a light virtual machine complete with it’s own Linux kernel, so you don’t have to setup a VM like I had to way back when. You also get better Docker integration on Windows. No more fumbling about with Docker commands in PowerShell without auto-complete.
Let’s get ourselves set up.
Enabling Windows Subsystem for Linux
First thing you need to do is make sure you are on Windows 10 version 2004. If you don’t have it, go ahead and run the Windows Update Assistant: https://www.microsoft.com/software-download/windows10
After running that update, restart your computer.
For the most part, Microsoft’s documentation is much better than anything I could write about the subject so I’ll be recommending their docs. One thing they don’t mention in the WSL setup page that I’ll link to later is that you may have to download the WSL2 kernel. I mention it because I had to grab it myself.
So let’s open up the WSL setup doc linked here.
You should enable the following features:
- Windows Subsystem for Linux
- Virtual Machine Platform
You can do that with the following snippet (make sure you’re running PowerShell or Command Prompt with admin rights):
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
After this you can restart your computer to enable the features, and then grab the WSL2 kernel mentioned earlier.
After that, I suggest continuing on with the WSL setup doc from where it says “Set WSL 2 as your default version”.
After you have a Linux distribution ready for use you can follow
this guide to setup Docker with WSL 2 support,
and toggle integration for your WSL distro. Once you do that, you’ll find that
docker is a symlink to the Docker binary on Windows:
$ which docker /usr/bin/docker $ file /usr/bin/docker /usr/bin/docker: symbolic link to /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker
AND it has bash auto-complete!
One suggestion I would add is using the Windows Terminal over the regular console you get when running your distribution, it’s much more comfortable and similar to the terminal emulators you may have experienced on macOS or Linux.
So far this is as far as I’ve pushed it, but I’m looking forward to using it with VS Code for easier development while at my Windows computers.
Thanks for reading!