Setting up WSL2 and the VSCode Remote Containers WSL Plugin
Tags: docker, vscode, wsl
Published: 2021-09-13 18:35:49

---
title: Setting up WSL2 and the VSCode Remote Containers WSL Plugin
published: true
date: 2021-09-13 17:11:52 UTC
tags: docker,vscode,wsl
canonical_url: https://www.jonathancreamer.com/setting-up-wsl2-and-the-vscode-containers-plugin/
---

 ![Setting up WSL2 and the VSCode Remote Containers WSL Plugin](https://www.jonathancreamer.com/content/images/2021/09/IMG_3519.JPG)

For years, macOS has been the gold standard for tooling when it comes to Web Development. The unix basis of macOS, iTerm, bash, VIM, etc are all things that folks building for the web platform rely on day to day.

That all changes with WSL2.

WSL2 allows web dev folks working in Windows to get the same goodness of macOS's unix based tooling running "more natively" on Windows.

Read more about how all this works:

- [Docker ❤️ WSL 2 - The Future of Docker Desktop for Windows - Docker Blog](https://www.docker.com/blog/docker-hearts-wsl-2/)
- [Introducing the Docker Desktop WSL 2 Backend - Docker Blog](https://www.docker.com/blog/new-docker-desktop-wsl2-backend/)

## Steps to install WSL2

### Step  1

Turn on WSL in a command prompt or Powershell.

```
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
```

### Step 2

Enable the Virtual Machine Platform

```
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
```

Probably should restart after this.

### Step 3

Install this [X64 Patch](https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi).

### Step 4

Make sure WSL2.0 is default.

```
wsl --set-default-version 2
```

### Step 4

Install Linux!

Go to the [Windows Store](https://aka.ms/wslstore), and find your favorite Linux.

e.g. [Ubuntu 20](https://www.microsoft.com/store/apps/9n6svws3rx71), [Alpine Linux](https://www.microsoft.com/store/apps/9p804crf0395)

### Optional other good stuff

That's it for WSL2 install, but there's more goodness you can get with...

### Install Windows Terminal

[Windows Terminal](https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701) is a brilliant app that manages all kinds of command prompts, terminals, etc. Read more about how to make [Powershell Pretty](https://www.jonathancreamer.com/making-powershell-pretty/).

![Setting up WSL2 and the VSCode Remote Containers WSL Plugin](https://www.jonathancreamer.com/content/images/2021/09/image-1.png)

By default it will work with Command Prompt and Powershell, but once you have WSL, and Linux installed, it'll also allow you to open Terminals straight into your Linux!

### Install Docker Desktop

Installing [Docker Desktop](https://www.docker.com/products/docker-desktop) allows you to install a new WSL2 based backend that speeds up working with Docker on Windows, adds a nice GUI on top of Docker that allows you to see your running containers visually, installs all the command line tools for docker like docker-compose, and allows you to install a small kubernetes cluster as well.

![Setting up WSL2 and the VSCode Remote Containers WSL Plugin](https://www.jonathancreamer.com/content/images/2021/09/image-2.png)

Read more [here](https://docs.docker.com/desktop/windows/wsl/).

## VSCode Remote Containers

### Step 1

Install the [Remote Containers - WSL](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) plugin.

### Step 2

Clone a Repo, or something in your Linux Distro.

![Setting up WSL2 and the VSCode Remote Containers WSL Plugin](https://www.jonathancreamer.com/content/images/2021/09/image-3.png)

### Step 3

Use the Command Palette (Control + Shift + P) and search for Remote-WSL to Open a Folder.

![Setting up WSL2 and the VSCode Remote Containers WSL Plugin](https://www.jonathancreamer.com/content/images/2021/09/image-4.png)

Choose the folder you want, and VSCode will now open the project connected directly to your Linux Distro.

![Setting up WSL2 and the VSCode Remote Containers WSL Plugin](https://www.jonathancreamer.com/content/images/2021/09/image-5.png)

Alternatively you can navigate to the repo in Terminal, and use `code .` which will also open VSCode connected directly to the Linux Distro.

## Conclusion

This post tried to be as clear and concise along the way to get up and running with WSL2 and VSCode as quick as possible. It's a huge productivity win for Web Dev folks working on Windows to be able to develop against Linux, so hopefully this will help accelerate those gains.

## BONUS PROTIP

You can also install the [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)plugin and test out different programming languages with the power of Docker.

![Setting up WSL2 and the VSCode Remote Containers WSL Plugin](https://www.jonathancreamer.com/content/images/2021/09/image-7.png)

![Setting up WSL2 and the VSCode Remote Containers WSL Plugin](https://www.jonathancreamer.com/content/images/2021/09/image-6.png)