<p>We have a requirement to build custom docker images from base docker images with some additional packages/customization. These custom docker images need to be then deployment into kubernetes. We are exploring various tools to figure out on how docker build can be done in kubernetes cluster (without direct access to docker daemon). Open source tools like kaniko provides the capability to build docker images within a container (hence in a kubernetes cluster).</p>

<ol>
<li><p>Is it a good practice is build docker images in kubernetes cluster where other containers will be run/executed? Are there any obvious challenges with kaniko?</p></li>
<li><p>Should separate dedicated VMs be created to manage the build process?</p></li>
</ol>

dinup24
<p><strong>1. Is it a good practice is build docker images in kubernetes cluster where other containers will be run/executed?
Are there any obvious challenges with kaniko?</strong></p>

<p>Yes, it is possible to build images inside <a href="https://kubernetes.io" rel="nofollow noreferrer">Kubernetes</a> containers, but it could be a bit of a challenge.</p>

<p>Some users use it to build a workflow for <a href="https://kublr.com/blog/using-jenkins-and-kubernetes-for-continuous-integration-and-delivery/" rel="nofollow noreferrer">CI/CD with Jenkins</a>. In fact, it is better to use tools to simplify the process.</p>

<p>Kubernetes also have rules to prepare containers development kit, they are described <a href="https://kubernetes.io/docs/concepts/containers/images/" rel="nofollow noreferrer">here</a></p>

<p>Another way is to use <a href="https://kublr.com/blog/using-jenkins-and-kubernetes-for-continuous-integration-and-delivery/" rel="nofollow noreferrer">Kaniko</a>, this tool builds container images from a Dockerfile inside a container or Kubernetes cluster.</p>

<p>I found this article interesting to read on this <a href="https://applatix.com/case-docker-docker-kubernetes-part-2/" rel="nofollow noreferrer">topic</a>.</p>

<p>On the other hand, there was a successful attempt to build images without Docker daemon running. You may be interested in <a href="https://bazel.build/" rel="nofollow noreferrer">Bazel</a> project and <a href="https://medium.com/bitnami-perspectives/building-docker-images-without-docker-c619061b13a9" rel="nofollow noreferrer">story</a> how to use it.</p>

<p><strong>2. Should separate dedicated VMs be created to manage the build process?</strong> </p>

<p>Regarding your second question: It is not necessary to set up dedicated VM to run Docker images creation workflow.</p>

<p>Finally, it may be interesting to have a <a href="https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/registry" rel="nofollow noreferrer">private registry</a> in Kubernetes cluster and use it for building purposes.</p>
