Product docsVirtualization & VDS
Use WSL 2 on Windows Server: Linux tools and Docker
Install WSL 2 on a Windows Server 2022 or 2025 VDS, turn on systemd, run Docker Engine inside the Linux distribution, limit resources and expose a port.
- Intermediate
- 25 min read
- Updated
On this page
WSL 2 (Windows Subsystem for Linux) runs a Linux distribution with a real Linux kernel right inside Windows. On a Windows VDS it gives you Linux command-line tools, scripts and containers next to your Windows software. WSL 2 uses virtualization, so it needs the nested virtualization that VDS plans include.
Before you start
- A Windows Server 2022 or 2025 VDS or nested dedicated server. Windows Server 2019 needs the manual steps from Microsoft's documentation.
- Remote Desktop access as administrator.
Step 1: Install WSL
Open PowerShell as administrator:
wsl.exe --installThe command enables the required components, downloads the Linux kernel, sets WSL 2 as the default and installs Ubuntu. Restart the server when it finishes:
Restart-ComputerAfter the restart, open Ubuntu from the Start menu (or run wsl) and create your Linux user name and password.
Verify:
wsl --list --verboseThe distribution shows VERSION 2.
To install another distribution, list the available ones and pick by name:
wsl --list --online
wsl --install -d DebianStep 2: Turn on systemd
Services such as Docker expect systemd. Many distribution images enable it already; check and, if needed, enable it inside the distribution:
cat /etc/wsl.conf
sudo nano /etc/wsl.confThe file needs these lines:
[boot]
systemd=trueThen restart WSL from PowerShell:
wsl --shutdownVerify: start the distribution again and run systemctl list-unit-files --type=service; it lists services instead of an error.
Step 3: Install Docker Engine inside WSL
Docker Desktop is not supported on Windows Server. Install Docker Engine in the Ubuntu distribution exactly as on a Linux server, from Docker's own repository: follow install Docker on Ubuntu inside WSL.
Verify: inside WSL, sudo docker run --rm hello-world prints "Hello from Docker!".
Step 4: Limit WSL's memory and CPU
By default the WSL virtual machine may use half of the server's memory and all of its processors. To leave room for Windows, create C:\Users\YourName\.wslconfig:
[wsl2]
memory=4GB
processors=2Run wsl --shutdown and start the distribution again for the limits to apply.
Step 5: Reach a Linux service
- From Windows on the same server: services inside WSL answer on
localhost, for examplehttp://localhost:8080. - From the internet: WSL 2 sits behind its own NAT. Forward a port of the server to the WSL address, as Microsoft describes, and open the firewall:
wsl hostname -I
netsh interface portproxy add v4tov4 listenport=8080 listenaddress=0.0.0.0 connectport=8080 connectaddress=172.30.98.229
New-NetFirewallRule -DisplayName "WSL 8080" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 8080 -Profile AnyUse the address wsl hostname -I printed as connectaddress. The WSL address can change after a restart; check it and update the rule with netsh interface portproxy show v4tov4. The service in WSL must listen on 0.0.0.0, not only 127.0.0.1.
Troubleshooting
Error: 0x80370102 The virtual machine could not be started because a required feature is not installed. WSL 2 cannot use virtualization. Check that you are on a VDS and that the Virtual Machine Platform component is installed and the server restarted; see nested virtualization problems.
Settings in .wslconfig or wsl.conf have no effect. WSL applies them only after the virtual machine has stopped completely. Run wsl --shutdown, wait a few seconds and start again.
The forwarded port stopped working after a restart. The WSL address changed. Update the connectaddress of the port proxy.
Next steps
- Full virtual machines with their own address space: Hyper-V on a Windows VDS.
- Containers in practice: Docker Compose basics.
Frequently asked questions
Can I install Docker Desktop on Windows Server?
No. Docker states that Docker Desktop is not supported on server versions of Windows. On Windows Server, install Docker Engine inside the WSL Linux distribution instead, or use a Windows desktop image.
Does WSL 2 work on a Windows VPS?
No. WSL 2 runs Linux in a lightweight virtual machine, so it needs nested virtualization, which our VDS and nested dedicated plans offer and VPS plans do not.
Should I run production services in WSL?
WSL is built for development and tools. For services that must run around the clock, use a Hyper-V virtual machine on your VDS or a Linux server, where the service starts with the system.
Which Linux distributions can I install?
Run wsl --list --online to see the distributions Microsoft offers, then install one with wsl --install -d and its name. Ubuntu is installed by default.