Member-only story

Set up Linux Dev Environment On Windows 10 Machine With WSL2, Docker, and Visual Studio Code

Chloe Sun
6 min readNov 30, 2020

--

Source: Unsplash

WSL 2

Why Use Windows Subsystem for Linux 2 (WSL 2)?

According to Microsoft doc, “the Windows Subsystem for Linux lets developers run a GNU/Linux environment — including most command-line tools, utilities, and applications — directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup.”

Unlike WSL 1, which uses a translation layer between Linux and Windows, the latest WSL 2 uses virtual machine technology to allow you to run a real Linux kernel directly on Windows 10. WSL 2 also allows you to run Docker natively on Windows 10.

Installation of WSL 2

You need to install WSL 1 and update to WSL 2, and here are the official instructions you’d need to follow. Just be aware to check if your Windows version meets the requirements for WSL 2.

Windows Requirements:

  • For x64 systems: Version 1903 or higher, with Build 18362 or higher.
  • For ARM64 systems: Version 2004 or higher, with Build 19041 or higher.
  • Builds lower than 18362 do not support WSL 2. Use the Windows Update Assistant to update your version of Windows.

You can select the Start button > Settings > System > About, to check which edition and version of Windows your device is running.

Another detail, in the official doc, Step 5 — Set WSL 2 as your default version, the command in PowerShell is :

wsl --set-default-version 2

I found this doesn’t work for me at first. Since I’ve had Ubuntu 20.04 installed already, I need to upgrade my existing Linux distro to v2 first, so you can add this step between Step 4 and Step 5. You could run this in PowerShell, and wait for a couple of minutes for the upgrade.

wsl --set-version <distro name> 2 // in my case, wsl --set-version Ubuntu-20.04 2

With the above command, you can change back to WSL 1 at any time by replacing the ‘2’ with a ‘1’.

At this point, the WSL 2 should be properly installed on your Windows10…

--

--

Chloe Sun
Chloe Sun

Written by Chloe Sun

<Architect | Software Developer | Metaverse Enthusiast> Discord: Architecting the Metaverse https://discord.com/invite/mZjcEbgyEH

No responses yet

Write a response