Microk8s local Docker image workflow with containerd

As a developer, I’m building docker images and testing them in a local microk8s environment.

With microk8s versions before 1.14, I used to build the images with microk8s’ own Docker, and they would be instantly usable in Pods:

sudo microk8s.docker build . -t mytag:latest
kubectl create -f mypod.yaml  # (in which I have "image: mytag:latest")

With microk8s 1.14, as I understand it, the included containerd in microk8s.ctr only can import and pull images but it has no build capability.

What would be a good replacement workflow if I don’t want to set up a registry?

Hi @akaihola, I know you said “no registry”, I just want to make sure you are aware of the microk8s.enable registry addon that creates an insecure registry on localhost:32000.

Hey @akaihola, to add to what @kjackal said, you can still use docker to build your images, there’s just no docker bundled with MicroK8s. But you can install docker however you’d like (as a snap, or using apt, etc.), build your images with it, and then docker push those to the microk8s registry.

Thanks kjackal and tvansteenburgh,

Yes, I did figure that going with a local registry would probably solve this for me, and I’ll try it out. I guess it’s effectively similar to doing this?

docker save myimage >myimage.tar
microk8s.ctr image import myimage.tar

Let’s see how much the registry method slows down the development iterations – pushing is an extra step after all.

Also, won’t I be spending three times the disk space on my laptop since there will be copies of the image in Docker, the registry and containerd?

That is a good point.

I’ve managed to use my local docker command and images are instantly available for microk8s, commented about it here How to use a local registry - #15 by WittyShizard