Cloud Native 8 min read

Enable Kubernetes in Docker Desktop: A Step‑by‑Step Guide

This guide walks you through installing Docker Desktop, configuring registry mirrors, running a PowerShell script to preload required images, enabling the built‑in Kubernetes cluster, and accessing the Kubernetes Dashboard, providing a complete solution for quickly setting up a local K8s environment on Windows or macOS.

Raymond Ops
Raymond Ops
Raymond Ops
Enable Kubernetes in Docker Desktop: A Step‑by‑Step Guide

Enable Kubernetes in Docker Desktop

Overview

As the de‑facto standard for container orchestration, Kubernetes is the foundation of modern applications, but many beginners get stuck at the first hurdle: obtaining a working K8s environment. Building a full cluster locally requires substantial hardware, so the simplest approach is to use the built‑in Kubernetes provided by Docker Desktop on Windows or macOS.

Step by Step

First, install Docker Desktop (just click Next). For better performance, use WSL 2 as the backend; the latest Docker Desktop defaults to WSL 2. The example uses version 3.3.1, which includes Kubernetes v1.19.7.

Choose a host backend:

WSL 2: enable "Windows Subsystem for Linux" in Windows Features, then install a Linux distribution from the Microsoft Store. 适用于 Linux 的 Windows 子系统 Hyper‑V: enable Hyper‑V in Windows Features (note that Hyper‑V may conflict with other VM software).

Hyper-V

2.1 Enable K8s Service

Because Docker Hub mirrors are slow, configure Docker Engine to use faster registry mirrors. Add the following JSON to the registry-mirrors field (using Docker’s official and USTC mirrors):

{ "registry-mirrors": [ "https://docker.mirrors.ustc.edu.cn", "https://registry.docker-cn.com" ], "insecure-registries": [], "debug": false, "experimental": false, "features": { "buildkit": true } }

After saving the configuration, restart Docker Desktop.

Clone the k8s-for-docker-desktop repository and locate the load_images.ps1 PowerShell script. This script pulls the required images from Alibaba Cloud, ensuring the image versions match the built‑in Kubernetes version, then loads them into Docker.

If PowerShell blocks script execution, run: Set-ExecutionPolicy RemoteSigned Once the script finishes, the images listed in images.properties will be present locally.

Open Docker Desktop settings, go to the Kubernetes page, check "Enable Kubernetes", and click "Apply & Restart". After a minute or two, the K8s cluster will start.

2.2 Enable Dashboard

After the cluster is up, you can deploy the Kubernetes Dashboard for a visual interface. In the cloned repository, apply the kubernetes-dashboard.yaml file: kubectl apply -f kubernetes-dashboard.yaml Check the deployment and pod status:

kubectl get deployment -n kubernetes-dashboard
kubectl get pods -n kubernetes-dashboard

Start a proxy to access the dashboard: kubectl proxy Retrieve the token for login:

$TOKEN=((kubectl -n kube-system describe secret default | Select-String "token:") -split " +")[1]
kubectl config set-credentials docker-for-desktop --token="${TOKEN}"
echo $TOKEN

Open the dashboard at:

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

Raymond运维
Raymond运维
Docker version
Docker version
Configure registry mirrors
Configure registry mirrors
Enable K8s service
Enable K8s service
Cluster information
Cluster information
Enable Dashboard
Enable Dashboard
Dashboard view
Dashboard view
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Kubernetesdashboardk8sPowerShellDocker DesktopWSL2
Raymond Ops
Written by

Raymond Ops

Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.