Combine Docker, Kubernetes and Windows WSL

Dennis Zimmer
Jul 9 · 4 min read

Combine Docker, Kubernetes and Windows WSL

When running Windows 10 on your laptop, there are a couple of new options you can explore that simplify your life when it comes to Linux integration and also Docker and even Kubernetes.

This blog post is briefly covering the installation of the Windows WSL (Windows subsystem for Linux), the configuration of Docker to enable Kubernetes. Finally we make sure that Linux docker and kubernetes management commands are able to connect from the WSL Linux to the Windows Docker and Kubernetes.

The WSL is really an amazing step to combine the best of Microsoft Windows and the best of Linux (Ubuntu in our example) with only a few limitations.

Please make sure to have the latest patch level of Windows 10 installed, so the WSL is no technical preview anymore.

To get the WSL feature enabled, just open an PowerShell console and run as Administrator and type:

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

If asked, please restart your computer before continuing.

Search for Linux in the Windows Store and install your preferred linux distribution. We go for Ubuntu 18.04 in this blog post.

Restart your system again, when requested and you have Linux installed inside the Windows WSL.

Next application to be installed is Docker. Docker uses the Hyper-V functionality of Windows, so please be aware, that a hypervisor is installed on your system including new network devices like a virtual switch.

IMPORTANT: That new virtual switch can mess your system up as sometimes the name resolution gets broken.

If you run into that issue, that makes opening new websites unbelievable slow, you should consider the following workaround.

Select change adapter options.

Select vEthernet (Default Switch) and Properties

add DNS server manually to your IP v4 and IP v6 settings.

IP v4 DNS examples:

  • Google DNS:
  • Quad9 DNS:

IP v6 DNS examples:

  • Google DNS: 2001:4860:4860::8888
  • Quad9 DNS: 2620:fe::fe, 2620:fe::9

Despite that nasty Hyper-V vSwitch issue Docker installation itself is extremely straightforward and you can find the download links and quickguide here:

Enable Kubernetes on Docker for Windows

Now you can get really excited because Kubernetes is part of the Docker for Windows installation in the meantime and only needs to be activated.

To do so, enter the Docker settings:

and enable Kubernetes:

That’s it! The moment you see the little green icon at the bottom left, your Kubernetes is up and running and ready to manage your docker setup.

Our goal is to control Docker and Kubernetes from within the Windows WSL, therefore we need to install the Docker and Kubernetes commands.

Lets start with Docker

sudo apt-get install apt-transport-https ca-certificates curl software-properties-commoncurl -fsSL | sudo apt-key add -sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"sudo apt-get update && sudo apt-get install docker-ce-cli

Now we need to combine the Linux installation with the Windows runtime:

echo "export DOCKER_HOST=tcp://localhost:2375" >> ~/.bashrc && source ~/.bashrc

As Docker likes to access the filesystem the same way, we also need to change the default WSL mountpoints for the Windows drive letters. Therefore we create a wsl.conf file that changes the mountpoints to c, d aso instead of /mnt/c aso.

Please create the file /etc/wsl.conf (sudo touch /etc/wsl.conf) and add the following content.

[automount] root = / options = "metadata"

We also need to configure Docker to expose the communication port on Port 2375:

To make sure all works, please restart your computer now.

The last step after the restart is the installation of the kubectl command. Open the Windows WSL (you can just type bash in the program search) and run the following commands:

curl -s | sudo apt-key add - echo "deb kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list sudo apt-get update && sudo apt-get install -y kubectl

Only one step left — linking the configs to the right location: Please make sure to change {Username} to your corresponding user homedirectory.

ln -s /c/Users/{Username}/.kube/config ~/.kube/config

Please test your new configured setup:

docker images kubectl get all

Sometimes I realized after a reboot or sleep mode resume, that Kubernetes is not starting automatically. The easiest way to force a restart is to change the docker dns and click apply:

Originally published at on July 9, 2019.


The Must-Read Publication for Aspiring Developers & DevOps Enthusiasts

Dennis Zimmer

Written by

Fullstack Monitoring, Analytics, Security: VMware, Docker, Kubernetes, Applications



The Must-Read Publication for Aspiring Developers & DevOps Enthusiasts

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade