<p>I have a docker container image that requires me to mount a volume containing a specific configuration file, in order for that container to properly start (this image is not one that I have control over, and is vendor supplied). If that volume is not mounted, the container will exit because the file is not found. So I need to put a configuration file in <code>/host/folder/</code>, and then:</p>
<pre><code>docker run --name my_app -v /host/folder:/container/folder image_id
</code></pre>
<p>The application will then look in <code>/container/folder/</code> for the file it needs to start.</p>
<p>I want to create/commit a new image with that file inside <code>/container/folder/</code>, but when that folder is mounted as volume from the host, <code>docker cp</code> will not help me do this, as far as I have tried. I think, as far as docker is concerned, the file copied there is no different than the files in the mounted volume, and will disappear when the container is stopped.</p>
<p>Part of the reason I want to do this, is because the file will not be changed, and should be there by default. The other reason is that I want to run this container in Kubernetes, and avoid using persistent volumes there to mount these directories. I have looked into using configmaps, but I'm not seeing how I can use those for this purpose.</p>

<p>If you can store the file into the <code>ConfigMap</code> you can mount the file to volume and use it inside the Kubernetes.</p>
<p>I am not sure with the <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#create-configmaps-from-files" rel="nofollow noreferrer">type of file</a> you have to use.</p>
<p><code>ConfigMap</code> will inject this file into the volume of a POD so the application could access and use it.</p>
<p>In this case there will be no PVC required.</p>
<p>You can also follow <a href="https://carlos.mendible.com/2019/02/10/kubernetes-mount-file-pod-with-configmap/" rel="nofollow noreferrer">this nice example</a> showing how to mount the file into a volume inside a pod.</p>
<p><strong>OR</strong></p>
<p>Also, I am not sure about the docker image but if you can use that docker image you can add the file into the path, something like:</p>
<pre><code>FROM &lt;docker image&gt;
ADD file ./container/folder/
</code></pre>
<p>In this case, you might have to check you can use the vendor docker image as a <strong>base</strong> and add the file into it.</p>
