Hands On Container wunderkind Docker has released a preview of Docker Desktop for Windows Subsystem for Linux 2.
This look at Docker Desktop 2 is based on Microsoft's work to make Windows Subsystem for Linux a complete virtual machine (VM) with its own full Linux kernel, instead of redirecting system calls as done in the first version of WSL. This means that the Docker Daemon can run in WSL instead of in a separate Hyper-V VM.
The existing Docker for Windows creates a VM with 2GB of RAM. WSL2 uses dynamic memory and CPU, which makes it more efficient and flexible in terms of resource usage.
The current technical preview of Docker Desktop for WSL 2 has a number of inconveniences. First, you need a recent "Insider" compilation of Windows 10, at least 18932. There are previous compilations that support WSL 2, but not the new Docker. Second, the only compatible Linux distribution is Ubuntu 18.04. Of course, you should also ensure that this runs in WSL 2 mode. You can convert it if necessary.
Once installed, you can toggle the Docker Desktop installation between traditional WSL 2 and VM modes. The WSL 2 Technical Preview option in the Docker Desktop context menu allows you to configure, start and stop the Docker daemon in WSL 2. Once in operation, you can switch between the two with the Docker context command, for example :  context of docker uses wsl
However, there is another nuisance, which is that the docker-compose command does not yet understand this context. This means that you can find that Docker containers are still running on the old VM Docker even when you thought it was configured for WSL. Having both running offers many possibilities for confusion and port conflicts.
The solution suggested by Docker engineer Simon Ferquel is to use an alternative solution using the DOCKER_HOST environment variable or use docker-compose from WSL. This second solution is easy when using Docker with remote Visual Studio Code communication, since you can have an open terminal in WSL within the editor. You can also take advantage of high-performance link mounting in WSL 2 to access the source files on the Windows side, or keep the source files on the Linux side.
The Docker daemon optionally runs in WSL in the new preview
This raises the question of what value WSL 2 is adding simply using a VM Linux, running locally or remotely. The main reason is to be able to use a complete Linux tool chain while still using a Windows editor such as Visual Studio Code and potentially having access to Windows applications such as Microsoft Office or Adobe Creative Suite applications for design work, without having to change machines
WSL 2 makes this scenario almost perfect. You can use Docker tools in Windows or in WSL 2 and both access the same Docker Daemon. Ferquel also points out some features to come, including VPN connectivity, reliable synchronization of the certification authority between the host and WSL running Docker and support for Kubernetes.
Docker Desktop for Windows also retains the ability to switch to using Windows containers, although this is primarily intended for legacy applications. Microsoft's efforts to support Linux with .NET Core and even SQL Server have the side effect of making Windows containers less necessary.
The current technical preview is for the brave, but when this is done, the combination of WSL 2, Docker and Visual Studio Studio's remote communication is close to achieving Microsoft's goal of making Windows 10 an excellent solution for container-oriented development.
That said, conceptually it is about ensuring that the creation and execution of your code takes place in Linux instead of Windows, something strange but necessary route for Microsoft to take. ®
Balancing consumerization and corporate control