After enabling Kubernetes in Docker Desktop for Windows, it simply wouldn’t come up. I waited about an hour but nothing happened. All needed Docker images etc. were downloaded but then the process stalled.
After searching for errors in all the different log files I found a bunch of lines like the following in C:\Users\%USERNAME%\AppData\Roaming\Docker\log\vm\kubelet.log
:
[026:09:01:30.415][I] E0126 09:01:30.415129 3471 reflector.go:138] k8s.io/client-go/informers/factory.go:134: Failed to watch *v1.Service: failed to list *v1.Service: Get "https://vm.docker.internal:6443/api/v1/services?limit=500&resourceVersion=0": dial tcp 192.168.65.4:6443: connect: connection refused
So, apparently the connection to https://vm.docker.internal:6443
could not be established.
I searched the web for solutions to this problem for quite a while, but finally came up with the reason myself: My antivirus software blocked access to the hosts
file! Docker couldn’t create the needed entries in C:\Windows\System32\drivers\etc\hosts
!
After allowing write access to hosts
in the antivirus software and restarting Docker Desktop, the following entries were created and Kubernetes finally started successfully.
# Added by Docker Desktop 192.168.178.76 host.docker.internal 192.168.178.76 gateway.docker.internal # To allow the same kube context to work on the host and the container: 127.0.0.1 kubernetes.docker.internal # End of section