Kubernetes Lab with Docker Desktop Guide¶
This lab shows a simple flow for running Kubernetes practice workloads with Docker Desktop. It is useful when you already use Docker Desktop and want a local Kubernetes cluster without managing a separate VM.
What You Will Learn¶
- Enable and verify Docker Desktop Kubernetes
- Confirm your current
kubectlcontext - Deploy a small application with a pinned image
- Expose the application locally
- Inspect pods, services, events, and logs
- Clean up the resources after testing
Prerequisites¶
- Docker Desktop installed
- Kubernetes enabled in Docker Desktop settings
kubectlavailable in your terminal- Enough CPU and memory allocated to Docker Desktop for a small cluster
Context matters
Docker Desktop usually uses the docker-desktop context. Always confirm the context before applying manifests so you do not accidentally deploy to another cluster.
Suggested Flow¶
- Enable Kubernetes in Docker Desktop.
- Confirm the current context with
kubectl config current-context. - Check cluster health with
kubectl get nodes. - Deploy a small sample workload and expose it with a Service.
- Clean up the resources after testing.
Step-by-Step Lab¶
Confirm your cluster context:
Create a namespace for the lab:
Deploy a small web server:
kubectl create deployment web --image=nginx:1.27 -n docker-lab
kubectl rollout status deployment/web -n docker-lab
Expose the Deployment:
kubectl expose deployment web --port=80 --target-port=80 -n docker-lab
kubectl port-forward service/web 8080:80 -n docker-lab
In another terminal, test the service:
Quick Validation¶
kubectl cluster-info
kubectl get nodes
kubectl get pods -A
kubectl get all -n docker-lab
kubectl logs deployment/web -n docker-lab
Troubleshooting¶
- If
kubectlcannot connect, confirm Kubernetes is enabled and Docker Desktop has finished starting. - If the context is wrong, switch with
kubectl config use-context docker-desktop. - If port
8080is busy, use another local port such as8081:80. - If the pod is pending, check Docker Desktop CPU and memory limits.
Cleanup¶
Next Steps¶
- Continue with the Minikube lab to compare local cluster workflows
- Practice larger examples in hands-on Kubernetes scenarios
- Review Kubernetes troubleshooting