Getting started with Docker on WSL 2 (Windows Subsystem for Linux).

Murtaza Haji
3 min readJun 12, 2020

--

A dummy’s guide to setting up WSL 2 backend and integrate with Docker

Windows 10 recently came out with an update (Windows 10 version 2004). This update enables Docker to run on WSL 2 which is substantially faster than the previous Hyper-V architecture for running containers. To learn more about their differences, checkout this link.

Unix Gang.

Enough talk, lets go ahead and setup Docker for WSL 2.

Step 1. Make sure your Windows is up to date(Windows 10 version 2004, build 19041).

Step 2. Enable WSL 2

Access Windows Features from Start Menu
Enable Windows Subsystem for Linux option

Open Powershell as Administrator and run the following command:

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform

Step 3. Run the following commands in the Powershell.

PS C:\WINDOWS\system32> wsl --set-default-version 2

Step 4. Restart your system and install Ubuntu from Windows Store.

If you have’nt installed already, click Get.

It might take a couple of minutes to setup the ubuntu system in terminal window. Setup username and password for the system.

Step 5. Open Powershell as Administrator and run the following commands:

PS C:\WINDOWS\system32> wsl -l -v

You should see the version for you Linux distro(Ubuntu) set as 2.

Step 6. Install Docker Desktop, open Dashboard and enable WSL 2 along with distro you want to use.

Ensure `Use the WSL 2 based engine` is checked.
Installed Linux distros will be displayed here, enable the ones you want to use with WSL 2.

Step 7. Open the Ubuntu terminal, start using docker integrated with WSL 2.

In conclusion, WSL was a nice attempt by Microsoft, to give users the feel of a linux kernel on a Windows system. But it always felt a bit gimmicky to me in the way that the file system worked.

WSL 2 is a major improvement over WSL and claims of being 5x faster in comparison to WSL are definitely accurate from my initial tests.

I hope the Docker integration can lead to increase in adoption of WSL 2 in Windows.

--

--