Setting Up WSL

WSL, the Windows Subsystem for Linux, allows you to work with Linux on Windows without having to go back and forth between different machines, dual booting or anything of the sort.

You can also use this to run Linux containers, which is a great way of isolating workloads and development environments.

I've been working more and more with both Android and Linux servers these last few years, and so being able to create little isolated environments is very handy.

OS Setup

I mostly followed the instruction from the Best practices for setup page.

I thought installing Ubuntu or Alpine (or CentOS would be the better choices, the former because it's the dfeault and so likely well supported, the latter because it's smaller and likely a better fit for the workloads I care about and for running on a Surface Pro. Ultimately I think I might want to play with GPU acceleration and all that, so I decided to start off with Ubuntu. wsl --list --online is the way to get the list of available distros.

The first command, wsl --install took a long while stuck at 0%, with a bunch of networking activity according to Task Manager, then zipped along.

Installing: Windows Subsystem for Linux
Windows Subsystem for Linux has been installed.
Installing: Ubuntu
Ubuntu has been installed.
The requested operation is successful. Changes will not be effective until the system is rebooted.

Technically I worked on a bunch of these things in some of the earlier iterations of Microsoft Mesh, but at this point I'm quite rusty and tools have improved substantially - WSL 2 was still a preview thing back then. I prefer to get my feet wet first.

After a reboot, I start Ubuntu from the Start menu, set up my user and paswword, and then at last: Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 5.15.146.1-microsoft-standard-WSL2 x86_64) - I have python, perl, awk, /bin/bash and more classics. A quick sudo apt update && sudo apt upgrade and I'm ready to rock and roll!

Containers

To set up and run containers, Get started with Docker remote containers on WSL 2 has you covered.

The setup workflow in general suggests having containers hooked up with vscode, which then remotely manages them - with your 'remote' containers being served by the distro VM.

Cleanup

To clean up the installation and start afresh, wsl --unregister Ubuntu would do the trick in my case.

Happy setups!

PS: as a callback, I wrote about GCC and Clang on Windows with Docker a few years ago.

Tags:  debugging

Home