title: What is the difference between subPath and mountPath in Kubernetes
body: <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>