<p>I'm deploying a basic &quot;solr:8.9.0&quot; image to local Kubernetes env.</p>
<p>If I'm trying to mount pod's &quot;/var/solr&quot; directory, it works well.
I can see the files inside /var/solr in the mounted directory.</p>
<pre><code>spec:
  containers:
  - image: solr:8.6.0
    imagePullPolicy: IfNotPresent
    name: solr
    ports:
        - name: solrport
          containerPort: 8983
    volumeMounts:
    - mountPath: /var/solr/
      name: solr-volume
  volumes:
  - name: solr-volume
    persistentVolumeClaim:
      claimName: solr-pvc
</code></pre>
<p>But somehow I can't mount &quot;/etc/default/&quot; directory. That doesn't work.
I knew there are files inside that directory but they are disappearing.</p>
<p>Any idea why?</p>
<p>Thanks!</p>

yatta
<p>this is because of how volumeMounts work.
A standard volumeMount mounts the volume in the suplied directory overwriting everything that is inside that directory.</p>
<p>You want to specify a subpath for the data you actually want to mount. By doing this the original contents of the directory won't get overridden.</p>
<p>see <a href="https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath" rel="nofollow noreferrer">here</a> for more information regarding the usage of subpaths.</p>
