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 Tech Preview, and it also requires the Windows 10 Insider Preview builds. 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.

Prerequisites

To run the Docker Desktop WSL 2 Tech Preview, 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.

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.

How to set up Docker and WSL 2

First, you will need to download the Docker Desktop WSL 2 Tech Preview here. Make sure you already configured all the WSL 2 steps described in the prerequisites, before you install the Docker WSL 2 Tech preview. 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.

Docker Desktop WSL 2 Tech Preview Menu

Docker Desktop WSL 2 Tech Preview Menu

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

Docker Desktop WSL 2 Tech Preview

Docker Desktop WSL 2 Tech Preview

You can switch between the classic daemon or the Windows Subsystem for Linux 2 with the following commands:

# Switch to classic deamon
 
docker context use default
 
# Switch to WSL 2
 
docker context use wsl
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.