Windows Subsystem for Linux

I was recently issued a new work laptop running Windows 11, and while I was a little hesitant after more than a decade of Linux for both work and personal use, I’ve been impressed with Windows Subsystem for Linux (WSL):

The Windows Subsystem for Linux lets developers run a GNU/Linux environment – including most command-line tools, utilities, and applications – directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup.

This post outlines the steps I took to install Ubuntu in WSL on Windows 11, configure Git and Docker, and connect everything to VS Code for a seamless local development experience.

Install WSL

  1. Install WSL from the Microsoft store
  2. Set WSL2 as the default version, by running the command wsl --set-default-version 2 in Windows Terminal
  3. Install Ubuntu 22.04 from the Microsoft Store
  4. Download and install the Linux kernel update package
  5. Open Windows Terminal and use the dropdown menu at the top to select Ubuntu 22.04
  6. Enter a username and password when prompted - this will be the username and password for your user account in Ubuntu, and it doesn’t have to match your Windows login

Ubuntu in WSL is now set up and ready to use! You can start it by clicking the Start Menu or pressing the Windows key and searching for Ubuntu, or from the dropdown menu in Windows Terminal:

Screenshot of Windows Terminal showing an option for Ubuntu 22.04

I generally only use Windows Terminal to interact with Ubuntu, so I went a step further and set Ubuntu as the default profile so I’m dropped straight in whenever I hit my terminal keyboard shortcut:

Screenshot of Windows Terminal settings, showing the default profile set to Ubuntu 22.04

Configure Git

  1. Generate a new SSH key by starting an Ubuntu terminal session and running ssh-keygen
  2. Add the new key to your GitHub (or other git repo hosting provider) account
  3. Configure Git with the following terminal commands in Ubuntu:
git config --global "Your Name"
git config --global ""

Install Docker

There are a couple of ways to handle Docker with WSL:

Method 1 - Docker Desktop for Windows

You can install Docker in Windows using Docker Desktop for Windows, and expose it to Ubuntu in WSL by navigating to Settings ➡️ Resources and activating the toggle for Ubuntu 22.04. Once toggled on, the output of docker help in an Ubuntu terminal session should be a list of available Docker commands. You’ll need to add your Windows user to the Docker group when using Docker Desktop for Windows.

⚠️ Note: You might also need a license to use Docker Desktop for Windows

Method 2 - Docker in Ubuntu

If you don’t want to use Docker Desktop for Windows, you can install Docker in Ubuntu directly. This is what I chose to do, as it more closely matches the setup I had before.

1. Enable systemd in Ubuntu

By default, Ubuntu in WSL boots with init. To support Docker it needs to boot with systemd. You can see which your Ubuntu instance has booted up with by running the following command in an Ubuntu session:

ps -p 1 -o comm=

If the output of the command is init, create a wsl.conf file by running the following command:

sudo nano /etc/wsl.conf

Add the following lines, and save and close the file:


Restart WSL by running the following command in a Windows PowerShell session (not Ubuntu):

wsl --shutdown

The next time you start Ubuntu and run the ps -p 1 -o comm= command, the output should be systemd.

2. Install Docker in Ubuntu

  1. Follow the docker installation docs for Ubuntu
  2. Add your user to the docker group by running the following command in an Ubuntu terminal session, replacing user with your Ubuntu username:
      sudo usermod -a -G docker user
  3. Verify Docker is installed by running docker help in Ubuntu. You should see a list of available Docker commands.

Connecting VS Code to WSL

VS Code is my editor of choice, and I installed the WSL extension to allow the editor to connect directly to Ubuntu in WSL.

The first time I opened a project in Ubuntu in WSL, I got the following prompt:

Screenshot of a VS Code notification suggesting reopening the project in WSL

Reopening the folder in WSL has VS Code connect to WSL directly, and you’ll see this indicated in the bottom left corner of the window:

Screenshot of VS Code showing a connection to WSL


With Ubuntu, Git, and Docker installed in WSL and VS Code set up, I can use Windows and keep all the tooling and development workflows I’m used to from Linux. There’s even direct filesystem access between the two; Ubuntu appears in Windows Explorer like a mounted network drive, and I can access Windows’ filesystem from within WSL as /mnt/c.

WSL has made the switch to Windows for work relatively painless, but I will of course be continuing to run Linux on my personal machines! 🐧