b.niki
b.niki

Reputation: 31

Is there any way to configure Skaffold to build images on my local Docker daemon and not on the minikube's one?

I use minikube with Docker driver on Linux. For a manual workflow I can enable registry addon in minikube, push there my images and refer to them in deployment config file simply as localhost:5000/anything. Then they are pulled to a minikube's environment by its Docker daemon and deployments successfully start in here. As a result I get all the base images saved only on my local device (as I build my images using my local Docker daemon) and minikube's environment gets cluttered only by images that are pulled by its Docker daemon.

Can I implement the same workflow when use Skaffold? By default Skaffold uses minikube's environment for both building images and running containers out of them, and also it duplicates (sometimes even triplicates) my images inside minikube (don't know why).

Upvotes: 1

Views: 759

Answers (1)

Brian de Alwis
Brian de Alwis

Reputation: 2964

Skaffold builds directly to Minikube's Docker daemon as an optimization so as to avoid the additional retrieve-and-unpack required when pushing to a registry.

I believe your duplicates are like the following:

$ (eval $(minikube docker-env); docker images node-example)
REPOSITORY     TAG                                                                IMAGE ID       CREATED      SIZE
node-example   bb9830940d8803b9ad60dfe92d4abcbaf3eb8701c5672c785ee0189178d815bf   bb9830940d88   3 days ago   92.9MB
node-example   v1.17.1-38-g1c6517887                                              bb9830940d88   3 days ago   92.9MB

Although these images have different tags, those tags are just pointers to the same Image ID so there is a single image being retained.

Skaffold normally cleans up left-over images from previous runs. So you shouldn't see the minikube daemon's space continuously growing.


An aside: even if those Image IDs were different, an image is made up of multiple layers, and those layers are shared across the images. So Docker's reported image sizes may not actually match the actual disk space consumed.

Upvotes: 2

Related Questions