WSL2, Docker, GUI

WSL and WSL2

Make sure that

You have Windows 10 version 1903 or higher, with Build 18362 or higher. If not, update it.

Check it by using Win+R, command winver

Virtualization is enabled inside of your computer’s BIOS

Enable WSL on …

WSL and WSL2

Make sure that

  • You have Windows 10 version 1903 or higher, with Build 18362 or higher. If not, update it.
    • Check it by using Win+R, command winver
  • Virtualization is enabled inside of your computer's BIOS

Enable WSL on Windows 10

  • Execute the commands below, using PowerShell on Admin mode:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
  • Open your PowerShell once again and try typing wsl, and if doesn't work, restart your machine

Upgrade to WSL2

wsl --set-default-version 2

(in case of error, ignore it this time)

Linux Distro

Install the Ubuntu distro (or any other you like)

  • Open your Microsoft Store, search for the Ubuntu App, select the Ubuntu app (which is the latest) and install it
  • After installed, configure your root user and password

Upgrade WSL version for Ubuntu

  • List your distro using wsl --list, via Powershell
  • Set your distro to WSL version 2
wsl --set-version <distro_name> 2


  • Access your WSL "space" on Windows through: (Win+R or explorer)
  • Find your Windows "space" on Linux:
  • Find your WSL "disk" on Windows:
    • in the case of Ubuntu, we have something like this:
  • Backup your WSL state:
wsl --export <distro> <output_file>                        # export
wsl --import <distro> <installation_location> <input_file> # import

or even, create a backup of the WSL "disk" file (previous item)

  • WSL2 uses almost all your machines resources, by default:
    • Disk and CPU
    • 80% of your available RAM
    • 25% of your available memory for Swap
    • You can set up limits, by creating a config file (example): C:\Users<User>.wslconfig >
  • Your custom configs are applied after a WSL restart:
wsl --shutdown

Windows Terminal

Windows Terminal is a new feature from Microsoft, improving your experience with terminals in Windows.

Install via Microsoft Store, by searching for Windows Terminal

With Windows Terminal you can:

  • you can change e.g. your Linux starting directory and default shell, when opening Windows Terminal:
"defaultProfile": "{xxxxx-xxxx-xxxx-xxxx}",
    "guid": "{xxxxx-xxxx-xxxx-xxxx}",
    "name": "Ubuntu-18.04", 
    "startingDirectory" : "//wsl$/Ubuntu-20.04/home/<ubuntu_user>", 


3 ways to use Docker on Windows

  • Docker Toolbox - bad

    • Uses Oracle VirtualBox
    • Very bad performance
    • Difficult setup and usage
  • Docker Desktop com Hyper-V - better

    • Uses Microsoft Hyper-V instead of VirtualBox
    • Requires Windows 10 PRO
    • Better performance but a heavy consumer of host resources
    • Docker will drop support in the future, as announced
  • Docker Desktop com WSL2 - recommended *

    • Uses Microsoft Virtual Machine Platform
    • Integrates with WSL2 and its distros
    • Better performance and consumes less resources
    • Usage as running on Linux natively

*Download and install Docker Desktop

Enable Docker on WSL2 distro
- Docker Desktop > Settings > Resources > WSL Integration
> Enable integration with additional distros > Check distro

Play with docker on WSL
- Open WSL and hit docker ps or try out docker run hello-world


A way to run Linux apps using WSL "builtin GUIs" is on the way, as one of the WSL improvements of Microsoft's roadmap.

While it still unavailable, we can still install a GUI and use RDP (Remote desktop manager), to access the Linux VM.

First of all, update and upgrade your Linux:

sudo apt update && sudo apt -y upgrade

Install (or overwrite) X-RDP:

sudo apt-get purge xrdp
sudo apt install -y xrdp

Install a GUI:

sudo apt install -y xfce4 # check 'gdm3' option
sudo apt install -y xfce4-goodies

XFCE is a lightweight GUI for testing purposes

Create a backup, config access, improve RDP session quality and define session:

sudo cp /etc/xrdp/xrdp.ini /etc/xrdp/xrdp.ini.bak
sudo sed -i 's/3389/3390/g' /etc/xrdp/xrdp.ini
sudo sed -i 's/max_bpp=32/#max_bpp=32\nmax_bpp=128/g' /etc/xrdp/xrdp.ini
sudo sed -i 's/xserverbpp=24/#xserverbpp=24\nxserverbpp=128/g' /etc/xrdp/xrdp.ini
echo xfce4-session > ~/.xsession

Edit XRDP startup script:

sudo nano /etc/xrdp/
  • Comment these last lines:
# test -x /etc/X11/Xsession && exec /etc/X11/Xsession 
# exec /bin/sh /etc/X11/Xsession 
  • Add these lines:
# xfce

Start RDP session:

sudo /etc/init.d/xrdp start

Access it from your Windows:

  • Execute command mstsc (Win+R)

Dev Projects

In my case, I moved all my project sources and repositories to WSL.

There are many softwares that already works integrated with WSL:

  • like VS Code for example, there are add-ons to work "remotely" with your projects in WSL
  • though I don't use IntelliJ, I've seen some videos and tutorials about doing it with WSL
  • on the other hand, there may be softwares that are more complex to integrate with WSL (or even don't)

In my case, I uninstalled everything from my host and installed Nvm on WSL

In this case, I couldn't create my workspace in WSL, so I kept it in my host computer.
I kept also maven installed in my host machine, and installed it also on WSL, but pointing dependencies to my host .m2/repository
However, I migrated my git repositories to WSL, and I'm opening it on my host workspace.
As I'm starting now using WSL, certainly I'm missing a better way to do it, I wonder, keeping both separate should not be the right way to do it, right?
If you can help me out, just drop me a line below. Also, I'll keep it updated as long I improve my dev workspace along with WSL.

See ya.

Source (pt-br)

Print Share Comment Cite Upload Translate
Select a language: