Operations 7 min read

Getting Started with WSL 2: Install and Use Linux on Windows with VS Code and Docker

This guide explains what WSL 2 is, its advantages over virtual machines, and provides step‑by‑step instructions for installing WSL, selecting a Linux distribution, and integrating it with VS Code and Docker to create a seamless development environment on Windows.

DevOps Engineer
DevOps Engineer
DevOps Engineer
Getting Started with WSL 2: Install and Use Linux on Windows with VS Code and Docker

What is WSL

WSL (Windows Subsystem for Linux) is a Windows 10 feature that lets you run a Linux file system, command‑line tools and GUI apps directly on Windows.

WSL's minimum version requirement is Windows 10 version 1903 or later.

WSL is aimed at developers who need Linux tools, such as network programmers, open‑source contributors, or anyone deploying to Linux servers.

It is suitable for users who prefer Bash, Linux utilities (sed, awk, etc.) and Linux‑first frameworks (Ruby, Python) while still using Windows productivity tools.

Advantages of Using WSL

Consumes far fewer resources (CPU, memory, storage) than a full virtual machine.

Allows simultaneous use of Windows and Linux and easy access to Windows files from Linux.

Combined with VS Code and Docker, it provides a Linux‑like experience together with Windows productivity, something a VM or pure Linux cannot match (Mac can, but not everyone prefers it).

Below is the installation process and how to pair it with VS Code and Docker.

Install WSL

wsl --install

This command enables the required optional components, downloads the latest Linux kernel, sets WSL 2 as the default, and installs a Linux distribution (Ubuntu by default).

# List available distributions
C:\Users\xshen>wsl --list --online
The following is a list of valid distributions that can be installed.
Install using 'wsl --install -d
'.

NAME            FRIENDLY NAME
Ubuntu          Ubuntu
Debian          Debian GNU/Linux
kali-linux      Kali Linux Rolling
openSUSE-42     openSUSE Leap 42
SLES-12         SUSE Linux Enterprise Server v12
Ubuntu-16.04    Ubuntu 16.04 LTS
Ubuntu-18.04    Ubuntu 18.04 LTS
Ubuntu-20.04    Ubuntu 20.04 LTS

Install another distribution, for example Debian:

wsl --install -d Debian

For more details, refer to the official documentation.

WSL + VS Code Demo

The following example uses Ubuntu to clone a repository and open the code folder in VS Code.

ubuntu@CN-L-2680:~$ git clone https://github.com/cue-lang/cue.git --depth 1
Cloning into 'cue'...
remote: Enumerating objects: 1833, done.
remote: Counting objects: 100% (1833/1833), done.
remote: Compressing objects: 100% (1502/1502), done.
remote: Total 1833 (delta 238), reused 1161 (delta 148), pack-reused 0
Receiving objects: 100% (1833/1833), 1.53 MiB | 5.39 MiB/s, done.
Resolving deltas: 100% (238/238), done.

Then change to the project directory and run code . :

ubuntu@CN-L-2680:~$ cd cue/
ubuntu@CN-L-2680:~/cue$ code .

# Only the first time will install VS Code Server
Installing VS Code Server for x64 (dfd34e8260c270da74b5c2d86d61aee4b6d56977)
Downloading: 100%
Unpacking: 100%
Unpacked 2341 files and folders to /home/ubuntu/.vscode-server/bin/dfd34e8260c270da74b5c2d86d61aee4b6d56977.

The first run automatically downloads and installs the VS Code Server, then launches your local VS Code and opens the Ubuntu code directory, providing a seamless experience.

Afterwards you can install any required software inside the WSL terminal using apt-get from VS Code.

Your local VS Code must have the Microsoft Remote - WSL extension installed. If you want to use Docker inside WSL, Docker Desktop must be installed on Windows beforehand.

References:

Documentation: https://docs.microsoft.com/en-us/windows/wsl/install

Remote - WSL extension: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl

Docker Desktop: https://www.docker.com/products/docker-desktop/

DockerLinuxDevelopment EnvironmentwindowsVS CodeWSL
DevOps Engineer
Written by

DevOps Engineer

DevOps engineer, Pythonista and FOSS contributor. Created cpp-linter, commit-check, etc.; contributed to PyPA.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.