How to Enable Kubernetes in Docker Desktop (Step‑by‑Step Guide)
This guide walks you through enabling Kubernetes in Docker Desktop on Windows or macOS, covering prerequisite setup, configuring registry mirrors, loading required images via a PowerShell script, activating the K8s service, and accessing the Kubernetes Dashboard for cluster visualization.
Enable Kubernetes in Docker Desktop
Overview
Kubernetes (K8s) is the de‑facto standard for container orchestration. Many beginners struggle to get a local K8s environment because setting up a full cluster requires significant resources. Docker Desktop on Windows or macOS provides a built‑in K8s that can be used for learning.
However, network restrictions often prevent Docker Desktop from pulling the required images from Google’s servers. This guide uses the k8s-for-docker-desktop project to work around those issues.
Step by Step
First install Docker Desktop (version 3.3.1 used here, which includes K8s v1.19.7). It is recommended to use WSL2 as the backend on Windows.
Before installing Docker, enable virtualization in BIOS. Depending on the chosen backend, you may need to:
Enable “Windows Subsystem for Linux” in Windows Features and install a Linux distribution from the Microsoft Store.
Enable “Hyper‑V” in Windows Features (note that Hyper‑V may conflict with other VM software).
2.1 Enable K8s Service
Docker Desktop’s K8s relies on images hosted on Google. Configure a registry mirror to speed up image pulls, e.g., using Docker’s official mirror and the USTC mirror:
{ "registry-mirrors": [ "https://docker.mirrors.ustc.edu.cn", "https://registry.docker-cn.com" ], "insecure-registries": [], "debug": false, "experimental": false, "features": { "buildkit": true } }Clone the k8s-for-docker-desktop repository and run the load_images.ps1 PowerShell script, which pulls the required images from Alibaba Cloud and ensures they match the Docker‑embedded K8s version.
If PowerShell blocks the script, set the execution policy: Set-ExecutionPolicy RemoteSigned After the script finishes, the required images appear in images.properties. Then open Docker settings → Kubernetes, check “Enable Kubernetes”, and click “Apply & Restart”. Wait a few minutes for the cluster to start.
When the K8s logo turns green, you can verify the cluster with kubectl get nodes or similar commands.
2.2 Enable Dashboard
For a visual interface, apply the kubernetes-dashboard.yaml manifest from the cloned repo: kubectl apply -f kubernetes-dashboard.yaml Start the proxy: kubectl proxy Access the dashboard at
http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/. Retrieve a login token with:
$TOKEN=((kubectl -n kube-system describe secret default | Select-String "token:") -split " +")[1]; kubectl config set-credentials docker-for-desktop --token="${TOKEN}"; echo $TOKENNote that using kubectl proxy each time is not optimal; a proper ingress configuration is recommended for production use.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
