<p>I'm running multiple containers in a pod. I have a persistence volume and mounting the same directories to containers.</p>
<p>My requirement is:</p>
<p>mount /opt/app/logs/app.log to container A where application writes data to <strong>app.log</strong></p>
<p>mount /opt/app/logs/app.log to container B to read data back from <strong>app.log</strong></p>
<pre><code>- container-A
  image: nginx
  volumeMounts:
  - mountPath: /opt/app/logs/ =&gt; container A is writing data here to **app.log** file
    name: data
- container-B
  image: busybox
  volumeMounts:
  - mountPath: /opt/app/logs/ =&gt; container B read data from **app.log** 
    name: data
</code></pre>
<p>The issue I'm facing is - when I mount the same directory <strong>/opt/app/logs/</strong> to container-B, I'm not seeing the <strong>app.log</strong> file.</p>
<p>Can someone help me with this, please? This can be achievable but I'm not sure what I'm missing here.</p>

Jwary
<p>According to your requirements, you need something like below:</p>
<pre><code>- container-A
  image: nginx
  volumeMounts:
  - mountPath: /opt/app/logs
    name: data
- container-B
  image: busybox
  volumeMounts:
  - mountPath: /opt/app/logs 
    name: data
</code></pre>
<p>Your application running on container-A will create or write files on the given path(/opt/app/logs) say app.log file. Then from container-B you'll find app.log file in the given path (/opt/app/logs). You can use any path here.</p>
<p>In your given spec you actually tried to mount a directory in a file(app.log). I think that's creating the issue.</p>
<p><b>Update-1:</b>
Here I give a full yaml file from a working example. You can do it by yourself to see how things work.</p>
<ol>
<li><p>kubectl exec -ti test-pd -c test-container sh</p>
</li>
<li><p>go to /test-path1</p>
</li>
<li><p>create some file using touch command. say &quot;touch a.txt&quot;</p>
</li>
<li><p>exit from test-container</p>
</li>
<li><p>kubectl exec -ti test-pd -c test sh</p>
</li>
<li><p>go to /test-path2</p>
</li>
<li><p>you will find a.txt file here.</p>
</li>
</ol>
<p>pvc.yaml</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: test-pv-claim
spec:
  storageClassName: 
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

</code></pre>
<p>pod.yaml</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: test-pd
spec:
  containers:
  - image: nginx
    name: test-container
    volumeMounts:
    - mountPath: /test-path1
      name: test-volume
  - image: pkbhowmick/go-rest-api:2.0.1 #my-rest-api-server                    
    name: test
    volumeMounts:
    - mountPath: /test-path2
      name: test-volume
  volumes:
  - name: test-volume
    persistentVolumeClaim:
        claimName: test-pv-claim
</code></pre>
