How to use local docker images with microk8s? How to use local docker images with microk8s? kubernetes kubernetes

How to use local docker images with microk8s?


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.


Unfortunately you did not provide microk8 version and your steps.

I supposed that you used sudo snap install microk8s --classic command to install. Currently it will download v1.14.0.
You can check your version using snap info microk8s

Version 1.14.0 introduced changes in microk8s.daemon-docker and change it to microk8s.daemon-containerd. Due to this change microk8s cannot execute docker commands. Microk8s contains daemon-docker between versions 1.11 and 1.13.

If you are used to use docker install microk8s v1.13 by sudo snap install microk8s --classic --channel=1.13/stable

For future use:

1) Install microk8s - sudo snap install microk8s --classic --channel=1.13/stable (if still want use docker)

2) Make sure that microk8s is started - microk8s.start (you can stop it by microk8s.stop)

3) Check what services are running by - microk8s.inspect

4) Commands in microk8s differs prefix, i.e instead of - kubectl get all --all-namespaces you need to use microk8s.kubectl get all --all-namespaces (later you can use allias to chage it)

5) You can create image via Dockerfile using microk8s.docker build . (don't forget to have Dockerfile and "." on the end of the command).

You can always check Microk8s documentation