<p>I am trying to add files in volumeMounts to .dockerignore and trying to understand the difference between subPath and mountPath. Reading official documentation isn't clear to me.</p>
<p>I should add from what I read mountPath is the directory in the pod where volumes will be mounted.</p>
<p>from official documentation: &quot;subPath The volumeMounts.subPath property specifies a sub-path inside the referenced volume instead of its root.&quot; <a href="https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath" rel="noreferrer">https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath</a> (this part isn't clear)</p>
<pre><code>- mountPath: /root/test.pem
            name: test-private-key
            subPath: test.testing.com.key
</code></pre>
<p>In this example should I include both test.pem and test.testing.com.key to dockerignore?</p>

girlcoder1
<p><code>mountPath</code> shows where the referenced volume should be mounted in the container. For instance, if you mount a volume to <code>mountPath: /a/b/c</code>, the volume will be available to the container under the directory <code>/a/b/c</code>.</p>
<p>Mounting a volume will make all of the volume available under <code>mountPath</code>. If you need to mount only part of the volume, such as a single file in a volume, you use <code>subPath</code> to specify the part that must be mounted. For instance, <code>mountPath: /a/b/c</code>, <code>subPath: d</code> will make whatever <code>d</code> is in the mounted volume under directory <code>/a/b/c</code></p>
