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.
I should add from what I read mountPath is the directory in the pod where volumes will be mounted.
from official documentation: "subPath The volumeMounts.subPath property specifies a sub-path inside the referenced volume instead of its root." https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath (this part isn't clear)
- mountPath: /root/test.pem
name: test-private-key
subPath: test.testing.com.key
In this example should I include both test.pem and test.testing.com.key to dockerignore?
mountPath
shows where the referenced volume should be mounted in the container. For instance, if you mount a volume to mountPath: /a/b/c
, the volume will be available to the container under the directory /a/b/c
.
Mounting a volume will make all of the volume available under mountPath
. If you need to mount only part of the volume, such as a single file in a volume, you use subPath
to specify the part that must be mounted. For instance, mountPath: /a/b/c
, subPath: d
will make whatever d
is in the mounted volume under directory /a/b/c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With