Installation of WSL2
WSL2 is needed to create a Linux environment to run the VS Code commands and Docker. Docker cannot run on a Windows computer without the WSL2 installed.
What is WSL?
Windows Subsystem for Linux WLS is a feature of Windows that allows you to run a Linux environment on your Windows PC, without the need for a separate virtual machine or dual booting. WSL enables developers to use the best of both Windows and Linux simultaneously. Without WSL one would need to run an operating system that behaves like a completely separate computer in an app window (virtual machine), or choosing a particular OS installed a priori during startup (dual booting).
WSL2, is the most up-to-date and widely supported version of the Linux distribution for windows.
WSL Installation
To install the WSL app, on your Windows PC, go to Start menu>Command Prompt and select Run as administrator. Type the following code:
wsl --install
This command will enable the features necessary to run Windows Subsystem for Linux (WSL) and install the Ubuntu distribution of Linux.
Once you have installed WSL, follow the Linux Distro setup instructions to the end. You will need to create a user account and password for your newly installed Linux distribution. Take note of these credentials.
If the WSL does not start after following the above steps, go to Microsoft Store and install the WSL app. Additionally, also install the Ubuntu app from Microsoft store.
Open the ubuntu app, follow the Linux Distro setup instructions.
Reboot your computer.
Go to Start menu, or type “WSL” in the search bar. Click on the WSL icon.
A text-based user interface such as the one below should appear.
Other Troubleshooting steps
In case the WSL app is present from the Start menu but clicking it does not open up WSL, follow the steps here
The above steps may be used to solve the following message that appears when one is starting WSL2.
However, if the issue persists, one may involve setting the virtualization via Basic Input/Output System (BIOS) of your laptop. For example, this link shows how to enable virtualization of your HP laptop.
It is important to know the specific laptop model to understand how to perform virtualization using the BIOS setup since instructions can even differ across various models of the same brand.
WSL2 Installation Errors
The following is a common error faced after installation of WSL2: the WSL2 terminal appears and then quickly disappears. To sort out this issue, follow the steps on this link. Fix 1 and Fix 2 should do the job.
To check if hypervisualization is enabled, a key component for WSL2 workability, there are two ways.
Method 1: Check windows features
Go to Start menu and type to Turn windows features on or off. Check that the Virtual Machine Platform, Windows Hypervisor Platform, and Windows Subsystem for Linux have been checked.
Restarting may be necessary if the settings have just been applied.
Method 2: Task Manager
Go to Task Manager>Performance. Check if virtualization is enabled. If it is disabled, and WSL2 is still not working after turning windows features on/off adjustments, then tweaking BIOS settings may be necessary.
Changing BIOS Settings
Changing the BIOS settings will differ between laptop brands. Browse the internet to search how to enable virtualization for your laptop model through the BIOS route. For example, here is a link showing how to enable BIOS in a HP laptop.