Docker & DevOps

WSL2 explained: run Linux on Windows for server work

How WSL2 runs a real Linux kernel in a lightweight Hyper-V VM, installing Ubuntu, using SSH, Docker and VS Code with it, networking and file performance tips, and when a VPS or VM is better.

BeginnerWindows 10 and 112 min read

WSL2 (Windows Subsystem for Linux 2) lets you run a real Linux environment inside Windows, ideal for managing servers, running scripts and developing web apps. Under the hood it uses a lightweight virtual machine with a genuine Linux kernel. This guide explains WSL2 and how to use it for server work.

Before you start

  • Windows 10 (recent build) or Windows 11 with virtualization enabled in firmware; see enable VT-x/AMD-V.
  • Administrator rights to install.

How WSL2 works

  • Windows runs a small utility VM on the Hyper-V platform with a Microsoft-maintained Linux kernel.
  • Each distribution (Ubuntu, Debian, etc.) runs as a container-like environment inside that VM.
  • It starts in seconds and shares files and networking with Windows.

Install WSL2

In an administrator PowerShell:

wsl --install

This installs WSL and Ubuntu by default. Restart when asked, then create your Linux username and password. List and install other distributions:

wsl --list --online

Use it for server work

  • SSH: generate keys in WSL with ssh-keygen -t ed25519 and connect to your VPS; see first steps on a new VPS.
  • Ansible and Terraform: run them from WSL as from any Linux machine; see Ansible.
  • VS Code: install the WSL extension and open projects inside Linux with code ..
  • Docker: Docker Desktop can use the WSL2 backend, or install Docker Engine directly inside a distribution.

File performance tip

Keep project files inside the Linux filesystem (e.g. ~/projects), not under /mnt/c. Cross-filesystem access is much slower. From Windows, open Linux files at \\wsl$.

Networking

  • Services running in WSL are usually reachable from Windows on localhost.
  • Recent Windows versions offer a mirrored networking mode (configured in .wslconfig) that improves VPN and IPv6 compatibility.

Limit resources

Create %UserProfile%\.wslconfig:

[wsl2]
memory=4GB
processors=2

Then run wsl --shutdown to apply.

WSL2 vs a VM vs a VPS

WSL2Local VM (VirtualBox, Hyper-V)VPS
Setup effortMinimalModerateMinimal
Feels like a real serverPartlyYesYes, with a public IP
Best forTools and developmentLabs, testing OS installsHosting real services

Frequently asked questions

Does WSL2 conflict with VirtualBox or VMware?

Modern versions of both can run alongside Hyper-V, sometimes with lower performance.

Can I host a website from WSL2?

For local testing, yes. For public hosting, use a VPS or web hosting.

Is systemd supported?

Yes, recent WSL versions support systemd when enabled in /etc/wsl.conf.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.