Use Linux Containers with WSL2 on Windows


Kubernetes with WSL

If you are working with Docker Desktop for Windows, you can also enable a Kubernetes cluster in the settings that allows you to develop Linux containers and manage them with Kubernetes (Figure 4). The Kubernetes tools are installed on activation; you can use them to manage the local Kubernetes cluster, as well as external clusters on the network.

Figure 4: For developers, Kubernetes can also be installed on Windows 10 machines.

In the settings, which you can access from the icon of the same name in Docker Desktop, click on Kubernetes and choose Enable Kubernetes ; if prompted, also Deploy Docker Stacks to Kubernetes by default . Then use Apply & Restart to create the Kubernetes cluster. If the cluster stops working, you can reset it with the Reset Kubernetes Cluster button. After creating the cluster, Kubernetes is available from the Kubernetes menu item in the context menu.

The Kubernetes cluster installation includes the kubectl tool. You can use it to administer Kubernetes locally and over the network. A set of commands that let you manage containers in Kubernetes is available, as well. You can also take this route to manage the Kubernetes cluster and display essential information about a cluster (Table 3).

Table 3

Helpful kubectl Commands

Command Function
kubectl cluster-info Check whether the cluster endpoint is working and display the cluster's IP address.
kubectl get services List services in the namespace.
kubectl get pods List pods in the current namespace.
kubetcl get pods --all-namespaces List all pods in all namespaces.
kubectl get pods -o wide List extended information about the pods in the general namespace.
kubectl get deployment <deployment> Show information about a specific deployment.
kubectl get nodes List nodes in the cluster.
kubectl describe Show further information for various objects on your screen. For example, kubectl describe nodes displays more detailed data about the nodes.

If you have a large number of pods in use in the cluster and only want to see the pods that currently have a Running status, use the command:

kubectl get pods --field-selector=status.phase=Running

If you want to list all pods in all namespaces with a status of Running , extend the command to include the --all-namespaces option.

Cluster with Docker Swarm

As an alternative to (or in parallel with) Kubernetes, you can use Docker Swarm to combine Windows-based container hosts and create a cluster. In such a configuration, it is possible to move containers between container hosts running Windows Server 2019 and Windows 10. To create one, use the docker tool in Windows.

To govern communication on the network, you will need some firewall rules, which you need to create in the Windows firewall. Communication between container hosts on UDP and TCP ports 2377, 7946, and 4789 must be allowed. The commands in Listing 1 create a Docker Swarm in Windows and show possible results.

Listing 1

Creating a Docker Swarm

docker swarm join --token <join token> <IP address of host>
docker swarm init --advertise-addr=<IP address of host> --listen-addr <IP address of host>:2377
docker swarm join --token SWMTKN-1-35yiqpp8hm5bypthomo0u6ip7h5mlxprneuvzeqy5c6mm5rke5-8dsgejlbdnte9iiqd4kiehkx8
docker swarm init --advertise-addr= --listen-addr


Linux containers can be deployed on Windows networks with Windows Server 2019 and Windows 10. Of course, to use containers in a production scenario, the performance has to be good. With this in mind, it makes sense to use version 2 of the Windows Subsystem for Linux, which is available for Windows 10 and for Windows Server 2004 and later.

Developers and administrators can deploy a full Linux container environment, including a Kubernetes cluster, on Windows 10 Pro and Windows 10 Enterprise. The Kubernetes tools are fully available in Windows 10 and enable the management of additional clusters on the network.

Containers in this environment can, of course, be moved to other container hosts. WSL is ideal for developing applications that run in Linux containers because no additional VMs need to be created. The containers rely on WSL to run directly in the Linux distribution on Windows and can be managed with the distribution's own tools. See the "Developing with Docker and WSL" box for other options.

Developing with Docker and WSL

Visual Studio Code and Visual Studio (VS) are possible solutions for developing applications for Docker that can then be run with WSL. Microsoft also offers the Remote-WSL [3] extension that you can use to design applications for containers that – in turn – can be deployed with WSL on Windows. The extension is usable from VS Code. Additionally, Microsoft offers the Remote-Containers [4] extension, which can also be used in combination with WSL.

The Author

Thomas Joos is a freelance IT consultant and has been working in IT for more than 20 years. In addition, he writes hands-on books and papers on Windows and other Microsoft topics. Online you can meet him on

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs

Support Our Work

ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.

Learn More”>


		<div class=