Windows sub-system Linux 101

unpublished draft
WSLDocker

Overview

Windows sub-system Linux (aka wsl) is a set of services that provide environment for installing many Linux distributions on top of windows. As of Windows 10 and above, WSL should be available at default and can be turn on or off with Windows Features.

Common installation

Useful to know

Installation#

Approach by global style (.wslconfig) file, should be locate at `%USERPROFILE%` (for all distributions)
[wsl2]
memory=8GB # Limits VM 8 GB memory in WSL
processors=2 # Makes the WSL 2 VM use two virtual processors
swap=32GB # Limits VM 32 GB storage in WSL - optional
swapFile=%USERPROFILE%\AppData\wslvhdx\swap.vhdx # Specify the actual swap file location - optional

Some useful command#

On window environment#

On WSL environment#

Docker related

Move docker data to another volume#

wsl --export docker-desktop-data E:\docker-desktop\docker-desktop-data.tar
wsl --unregister docker-desktop-data
wsl --import docker-desktop-data E:\docker-desktop\data E:\docker-desktop\docker-desktop-data.tar --version 2

Docker specific#


Khanh Nguyen

Web developer & .Net lover