DEV Community


Posted on • Updated on

WSL 2 Docker Docker Kubernetes on WSL 2

Windows Subsystem for Linux (WSL) is a component which was introduced in Windows 10 that provides a Linux environment for development on Windows. The Linux environment works by proxying Linux kernel commands to the Windows kernel.

WSL2 is the second iteration over WSL which creates a virtualized Linux environment and new features such as filesystem access using the native Windows explorer application, Docker and more. WSL2 also provides notable performance improvements over the first version.

This guide will go over what is required to set up a functioning Kubernetes development environment using Windows 10, WSL2, Visual Studio Code, and Docker.

Installing WSL

[ Edit ]: I've heard news that the may 2020 release of Windows 10 was just released. WSL 2 should be considered GA now.
⚠ At the time of writing, WSL2 is currently a release preview with anticipated General Availability release planned for Summer 2020. WSL2 can be downloaded by first moving into the "Release Preview" ring of the Windows Insider Program. WSL2 requires Windows build 2004 or later.

After the upgrade to Windows build 2004, WSL can be installed using the following instructions

Due to past experiences, I've installed Debian for its performance and ease-of-use.

Installing Docker

With WSL2 installed, Docker will need to be installed. Docker is a tool used to create, run, and orchestrate containers. Containers are self-contained environments that applications can run on. Docker can be downloaded from the download page

Once Docker is download it, install it by running the downloaded executable file. During the docker installation process, a prompt will display asking whether to enable the WSL 2 backend or not. Select yes when this prompt is displayed.

The WSL backend for Docker can also be turned on post-install by accessing the settings menu

Docker Settings

From the settings menu, select the General tab and check the box next to Use the WSL 2 based engine

WSL2 Engine

Enabling Kubernetes

Once Docker has been installed and the WSL 2 Backend has been enabled, Kubernetes on Docker can be enabled by switching to the Kubernetes tab on the Docker settings window and checking the Enable Kubernetes checkbox.

Enable Kubernetes Setting

Advantages of Kubernetes in Docker

Using Kubernetes in Docker means skipping on complicated installation instructions such as setting up CLI tools like kubeadm or k3s.

Using Kubernetes in Docker also means not having to set up a CNI layer such as calico, or flannel.

Docker provides a load balancer which allows traffic to be ingressed through localhost.

Docker for Windows will also set up the CLI tools which are used with both Kubernetes and Docker such as the Docker CLI and kubectl once the container engine is running.

Advantages of Kubernetes in WSL 2

I migrated from using Kubernetes in Minikube. I found Minikube -- even with the HyperV backend to be cumbersome and resource intensive.

WSL by comparison allowed me to deploy more containers so that I can test multiple applications at a time.

Top comments (5)

jeromesnail profile image
Jérôme Meichelbeck


I know this is an old post, but I'm trying anyway...

I tried to make function kubernetes on WSL2 (Ubuntu 20.04 LTS) with docker for desktop and I' just getting crazy because I can't make it work properly.

The kubectl command works like 1 time out of 10 and this is really frustrating. I tried to reinstall Docker completely. I even uninstalled and reinstalled Unbuntu, but I always have the same problem. The kubectl work, then it hangs and I get the famous message: "unable to connect to Kubernetes: an error on the server ("") has prevented the request from succeeding", and then it works again... or not. It seems so random...

I have Docker Desktop 3.3.1 (63152) on Windows 10 20H2, Kubertentes v1.19.7.

I'm going crazy.

Thank for your help !

mikeyglitz profile image

Just saw this. Let me see if I can get the same problem and I'll get back to you. In the mean time, I heard there are some issues with WSL and docker because you have to translate NTFS file system to EXT.

mikeyglitz profile image

I tried it out on my machine. I know if you're managing multiple Kubernetes clusters, you have to select the one you want to use when you use the kubectl commands with the following options from the Docker for Windows icon on the system tray:

System tray icon > Docker > Kubernetes > Context (select your cluster)

I am noticing issues with the latest version of the Docker client. Doesn't seem to be initializing and there's issues with trying to get the Docker for Windows to restart.

I used to be able to resolve docker issues by running the following commands in Windows terminal

wsl -t docker-desktop
Enter fullscreen mode Exit fullscreen mode
shrubberer profile image

Very interesting, thank you!
Is it possible to run multiple kubernetes nodes?

mikeyglitz profile image

If you liked this post and want to see more, I'm working on a playground project to continue my Kubernetes journey on GitHub