Problem in setting up Kubernetes in WSL (Failed to start docker.service: Unit docker.service not found)

I am following this procedure to setup Kubernetes in WSL: WSL Kubernetes Setup

I proceeded to setup kubernetes using Minikube. After the step of enabling SystemD, when I run,

sudo minikube start --driver=none

I get the following error,

Exiting due to RT_DOCKER_EXIT_5: sudo systemctl start docker: exit status 5
stdout:

stderr:
Failed to start docker.service: Unit docker.service not found.

What should be done to resolve this?

You need to install docker:

sudo apt install docker.io

Kind regards,
Stephen

Is it necessary to install docker locally in the wsl? I already have docker for windows and wsl integration enabled.

1 Like

@stephendotcarter as mentioned by @Avinash_S, the tutorial at WSL Kubernetes Setup explicitly mentions that there is no need to install docker on WSL, minikube should use the docker installation on the host Windows system. I’m facing the exact same issue and cannot figure it out

Did you follow this part of the guide to integrate Docker in to the WSL distro?

In order to fix it, and finally be able to use the commands, we need to tell the Docker Desktop to "attach" itself to our distro also:

Kind regards,
Stephen

@stephendotcarter yes I did. Docker works fine otherwise on WSL. I can run containers and everything. The issue is just when starting minikube.
Seems like the Host docker installation doesn’t register itself as a service inside WSL, and minikube is relying on that. I cannot find a work around for this

Checkout this thread:

I had the same error as you and got it to work using:

minikube start --driver=docker

Kind regards,
Stephen

@stephendotcarter thank you! this worked for me

1 Like