Written by 6:38 pm Microsoft, PowerShell, Virtualization, Windows, Windows Server • 19 Comments

Run Linux Containers with Docker Desktop and WSL 2

Docker Desktop WSL 2 Tech Preview

Today, Docker launched the first Tech Preview of the Docker Desktop WSL 2. This means you can now use Docker Desktop and the Windows Subsystem for Linux 2 (WSL2) which is using the hypervisor in the background to run Linux containers on Windows 10. With the significant changes to the Windows Subsystem for Linux 2, you can now take advantage of these improvements with your Docker Desktop client.

Docker Desktop WSL 2 is currently in the edge version of Docker, and it also requires the Windows 10 Insider Preview builds for Windows 10 version 2004. That means you should only use for not production environments.

WSL 2 introduces a significant architectural change as it is a full Linux kernel built by Microsoft, allowing Linux containers to run natively without emulation. With Docker Desktop WSL 2 Tech Preview, users can access Linux workspaces without having to maintain both Linux and Windows build scripts.

Docker Desktop also leverages the dynamic memory allocation feature in WSL 2 to greatly improve the resource consumption. This means, Docker Desktop only uses the required amount of CPU and memory resources, enabling CPU and memory-intensive tasks such as building a container to run much faster.

You can find more information about the Tech Preview here.


To run the Docker Desktop WSL 2, you will need to set up the Windows Subsystem for Linux 2 (WSL 2) first. You can do that using the following guide, or follow these steps:

Install Windows 10 Insider Preview build 18932 or later. WSL 2 will be available in Windows 10, version 2004. Today, you will need to install the Windows Insider Slow ring build.

Install the Windows WSL feature and the Windows Virtual Machine Platform feature running the following commands:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform

Download WSL Linux distribution based on Ubuntu 18.04 from the Microsoft Store. You can read more about Linux on Windows 10 here. The distribution needs to be set as the default WSL distro.

Enable Virtual Machine Platform

Enable Virtual Machine Platform

Make sure that the WSL distro is running in WSL 2 mode. You can check the list of distros installed on your Windows 10 machine, with the following PowerShell command:

wsl -l -v

To set the distro to WSL 2, you can run the following command. Change the name of the distro:

wsl --set-version DistroName 2
Install WSL 2

Install WSL 2

To find out more about installing WSL 2, check out the Microsoft Docs page.

You also set WSL 2 as the default for all Linux distros:

wsl --set-default-version 2

How to set up Docker and WSL 2

First, you will need to download the Docker Desktop for Windows Edge here. Make sure you already configured all the WSL 2 steps described in the prerequisites, before you install the Docker. If you are prompted if you want to use Linux containers or Windows containers during the installation, select Windows containers. If you choose Linux containers, you will have the classic Docker experience with a Hyper-V VM.

Install Docker for Windows and enable WSL 2

Install Docker for Windows and enable WSL 2

Run the installation wizard, and after a successful installation, the Docker Desktop menu displays the WSL 2 option. You can select WSL 2 from that menu to start and configure the daemon running WSL 2.

Docker for Windows Settings WSL 2

Docker for Windows Settings WSL 2

Now you can run a Linux container using Docker Desktop for Windows, running on Windows 10 using the Windows Subsystem for Linux 2 (WSL 2).

Linux Container on Windows 10

Linux Containers on Windows 10

You can now also do crazy things like run SQL Server on Linux in a Docker container on Windows 10.

SQL Server on Linux Docker Container Windows 10 WSL 2

SQL Server on Linux Docker Container Windows 10 WSL 2

I hope this gives you a good overview of how you will be able to run Linux containers on Windows in the future. Again this is still a Tech Preview, and we might see many changes to that feature. If you want to know more, read the full blog post on the Docker page. Also, check out the current Linux Container on Windows documentation. If you any questions, feel free to leave a comment.

Tags: , , , , , , , , , , , , Last modified: March 21, 2020