<p>My project has an application server and a C++ library. The library is not dependent on the application server. The vendor has a Docker image for the application server. I need to deploy a C++ library that needs to be accessible from each of the application server nodes/pods.</p>

<p>I've written a Dockerfile that builds on the vendors image, compiling and copying the libraries into place. It works, however, every time there's a new version of the application server I need to build my C++ library again from scratch. Given the lack of dependencies these doesn't seem optimal.</p>

<p>Naively, what I was expecting was to be able to build the C++ library into an "empty" image and mount that (like a filesystem) in each pod. That way the server and the library are maintained separately.</p>

<p>Is building on the vendor Dockerfile the "right" way to architect this? Or is there a solution more like my "idealised" vision?</p>

<p>I expect the answer is obvious and I just need the right terminology to search for... pointers very much appreciated.</p>

Stephen Darlington
<p>Using Kubernetes you have at least two options to manage the library separately from container image:</p>

<ol>
<li><a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/" rel="nofollow noreferrer">Init containers</a>. If you put your library to external resource you can use <code>Init container</code> to <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-initialization/" rel="nofollow noreferrer">download</a> it and put inside the application server's pod file system. </li>
<li><a href="https://kubernetes.io/docs/concepts/storage/volumes/#types-of-volumes" rel="nofollow noreferrer">Volumes</a>. You can also put the library to a network storage and attach it as a volume in <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes" rel="nofollow noreferrer">ReadOnlyMany</a> access mode to the application server pods.</li>
</ol>
