<p>I am new to kubernetes and experimenting with volumes. I have a docker image which declares 2 volumes as in :</p>

<pre><code>VOLUME ["/db/mongo/data" , "/db/mongo/log"]
</code></pre>

<p>I am using a StatefulSet , wherein I have 2 volume mounts, as in --</p>

<pre><code>volumeMounts:
            - name: mongo-vol
              mountPath: &lt;&lt; path1 &gt;&gt;
              subPath: data
            - name: mongo-vol
              mountPath: &lt;&lt; path2 &gt;&gt;
              subPath: log
</code></pre>

<p>My question is i) should path1 &amp; path2 be mentioned as "/db/mongo/data" and "/db/mongo/log" respectively ?? </p>

<p>ii) Or it can be any path where the volumes would be mounted inside the container, and "/db/mongo/data" &amp; "/db/mongo/log" container paths would be automatically mapped to those mount points ?</p>

<p>I tried reading up the documentation and tried both options but some confusion still remains. Appreciate some help here.</p>

Rajesh
<p>Your both volume mounts reference to the same volume <code>mongo-vol</code>. That tells me this is a volume containing the <code>data</code> and <code>log</code> directories. You should use <code>/db/mongo/log</code> and <code>/db/mongo/data</code> as your <code>mountPath</code>s, and specify the <code>subPath</code> as <code>log</code> and <code>data</code> respectively. That will mount the volume referenced by <code>mongo-vol</code>, and mount <code>data</code> and <code>log</code> directories in that volume on to those directories.</p>

<p>If you had two seperate volumes, a <code>mongo-data</code> and <code>mongo-log</code>, then you would mount them the same way, without the <code>subPath</code>, because you are not referencing sub-directories under the volume.</p>
