How to use local docker images with microk8s?

techrider picture techrider · Mar 22, 2019 · Viewed 10.9k times · Source

I have been using minikube to test Kubernetes locally. In minikube, we can use local docker images by using eval $(minikube docker-env) command.

I started to explore microk8s. Installed microk8s using snap on my machine running on Ubuntu 18.

Is there any way to use local docker images with microk8s like we use minikube for testing and development other than creating local docker registry?

microk8s.docker command is also not working, it's showing:

Command 'microk8s.docker' not found, but can be installed with:

snap install microk8s

but its already installed.

Answer

Naveen Kulkarni picture Naveen Kulkarni · Feb 22, 2020

microk8s has a private registry which can be used for this purpose.

You must enable the registry prior, with the following command

$ microk8s.enable registry

The registry maps the traffic to port 32000, so you will have to push your docker image to the registry. If the image is already present in local you can use docker tag command.

$docker tag <imageName:version> localhost:32000/<imageName:version>

$docker push localhost:32000/<imageName:version>.

use https://microk8s.io/docs/registry-built-in for more information.