<p>I need to install some libraries in my pod before it starts working as expected.</p>
<p>My use case: I need some libraries that will support SMB (samba), and the image that I have to use does not have it installed.</p>
<p>Unfortunately, exec'ing into the actual pod and running commands do not seem to be a very good idea.</p>
<p>Is there a way by which I can use an init-container to install <code>libsmbclient-dev</code> in my ubuntu pod?</p>
<p>Edit: Some restrictions in my case.</p>
<ol>
<li>I use helm chart to install my app (nextcloud). So I guess I cannot use a custom image (as far as I know, we cannot use our own images in an existing helm chart). This would have been the best solution.</li>
<li>I cannot run commands in kubernetes value.yaml since I do not use <code>kubectl</code> to install my app. Also I need to restart apache2 after I install the library, and unfortunately, restarting apache2 results in restarting the pod, effectively making the whole installation meaningless.</li>
</ol>
<p>Since nextcloud helm allows the use of initcontainers, I wondered if that could be used, but as far as I understand the usability of initcontainers, this is not possible (?).</p>

Prasannjeet Singh
<p>You should build your own container image - e.g. with docker - and push it to a container repository that is suitable for your cluster, e.g. Docker Hub, AWS ECR, Google Artifact registry ...</p>
<p>First install docker (<a href="https://docs.docker.com/get-docker/" rel="nofollow noreferrer">https://docs.docker.com/get-docker/</a>)</p>
<p>create an empty directory and change into it.
Then create a file <code>Dockerfile</code> with the following content:</p>
<pre><code>FROM ubuntu:22.04
RUN apt-get update &amp;&amp; apt-get install -y libsmbclient-dev \
  &amp;&amp; rm -rf /var/lib/apt/lists/*
</code></pre>
<p>Execute</p>
<p><code>docker build -t myimage:latest .</code></p>
<p>This will download Ubuntu and build a new container image where the commands from the <code>RUN</code> statement will be executed. The image name will be <code>myimage</code> and the version will be <code>latest</code>.</p>
<p>Then push your image with <code>docker push</code> to your appropriate repository.</p>
<p>See also Docker best practices:
<a href="https://docs.docker.com/develop/develop-images/dockerfile_best-practices/" rel="nofollow noreferrer">https://docs.docker.com/develop/develop-images/dockerfile_best-practices/</a></p>
