Replacing Docker Desktop with WSL2 and/or Rancher Desktop on Windows

Docker Engine on Linux via WSL2

Note in the above announcement that it says “that licensing for Docker Engine and the upstream Docker and Moby open source projects is not changing.” Docker Engine for Linux is fully open sourced (under the Apache license) and we can continue to use that for free. What Docker Desktop gave us in addition to that on Windows was running a Linux VM they set up for us wrapped around it (these days also running via WSL2), installation of the local CLI for docker and kubectl to map through to that VM, as well as installing a containerised Kubernetes in that VM for us optionally as well.

  • It automatically maps the ports through so that you can do a docker run -p 8080:8080 and then go to http://localhost:8080 in your browser on the Windows side
  • Not only can you run your docker commands and scripts within WSL2 instead of via the Command Prompt or PowerShell but many IDEs like Visual Studio Code can sync your code to the WSL side and run things there natively. This is detailed for VS Code here — https://code.visualstudio.com/blogs/2019/09/03/wsl2

Rancher Desktop for Kubernetes

That sorts us out for straight docker commands for our Linux containers, but what about the local Kubernetes it provided? There are various ways you could do that also in Ubuntu under WSL (kind etc.) but I also recently stumbled on Rancher Desktop which is free and open source and seems to be a great new tool for this use-case. I decided to give it a try.

  • Installs a new Linux VM in WSL2 that has a Kubernetes cluster based on k3s as well as installs various components in it such as KIM (for building docker images on the cluster) and the Traefik Ingress Controller
  • It installs the kubectl and Helm CLIs on the Windows side linked to them
  • A nice Windows app to manage its settings and help facilitate its upgrades
pod/coredns-7448499f4d-rtczv
pod/helm-install-traefik-crd-cptbv
pod/helm-install-traefik-jpz4b
pod/local-path-provisioner-5ff76fc89d-9rpn8
pod/metrics-server-86cbb8457f-hszhp
pod/svclb-traefik-cn88g
pod/builder-vk9gm
pod/traefik-97b44b794-q56mm
service/kubernetes
service/kube-dns
service/metrics-server
service/builder
service/traefik
daemonset.apps/svclb-traefik
daemonset.apps/builder
deployment.apps/coredns
deployment.apps/local-path-provisioner
deployment.apps/metrics-server
deployment.apps/traefik
replicaset.apps/coredns-7448499f4d
replicaset.apps/local-path-provisioner-5ff76fc89d
replicaset.apps/metrics-server-86cbb8457f
replicaset.apps/traefik-97b44b794
job.batch/helm-install-traefik-crd
job.batch/helm-install-traefik
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-kubernetes
spec:
replicas: 2
selector:
matchLabels:
app: hello-kubernetes
template:
metadata:
labels:
app: hello-kubernetes
spec:
containers:
- name: hello-kubernetes
image: paulbouwer/hello-kubernetes:1.10
ports:
- containerPort: 8080
resources:
requests:
memory: "512Mi"
cpu: "0.5"
limits:
memory: "512Mi"
cpu: "0.5"
readinessProbe:
httpGet:
scheme: HTTP
path: /
port: 8080
livenessProbe:
httpGet:
scheme: HTTP
path: /
port: 8080
---
apiVersion: v1
kind: Service
metadata:
name: hello-kubernetes
spec:
type: ClusterIP
ports:
- port: 80
targetPort: 8080
selector:
app: hello-kubernetes
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hello-kubernetes
annotations:
kubernetes.io/ingress.class: traefik
spec:
rules:
- http:
paths:
- path: "/"
pathType: Prefix
backend:
service:
name: hello-kubernetes
port:
number: 80
NAME               CLASS    HOSTS   ADDRESS         PORTS   AGE
hello-kubernetes <none> * 172.19.152.78 80 79s

Conclusion

With the seeming exception of Windows containers, I feel that the combination of docker engine via WSL2 for when you need docker and Rancher Desktop for when you need a local Kubernetes experience is a great free alternative to Docker Desktop on Windows.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store