<p>I am trying to create and delete file from the same pod and get error that the file not found, any idea?</p>
<p>one container creates the file and the second should delete it...</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  volumes:
    - name: shared
      emptyDir: { }
  containers:
    - name: createfile
      image: debian
      command: [ &quot;/bin/sh&quot;, &quot;-c&quot; ]
      args:
        - while true; do
          touch /usr/test.txt;
          ls
          echo &quot;new file created on container&quot;;
          sleep 30;
          done
      volumeMounts:
        - name: shared
          mountPath: /usr/
    - name: deletefile
      image: debian
      volumeMounts:
        - name: shared
          mountPath: /usr/
      command: [ &quot;/bin/sh&quot;, &quot;-c&quot; ]
      args:
        - while true; do
          rm /usr/test.txt;
          ls
          echo &quot;container 2 - file removed&quot;;
          sleep 30;
          done
</code></pre>
<p>The error which I got is:
<code>ls: error while loading shared libraries: libpcre2-8.so.0: cannot open shared object file: No such file or directory</code></p>
<p>Is it because I am running <strong>ls</strong> in the container, any idea why?
As I use Debian, not sure what is the issue</p>

JME
<p>Yes, the error was linked to the debian image (there is few solutions here:<a href="https://stackoverflow.com/questions/8501163/error-while-loading-shared-libraries-libpcre-so-0-cannot-open-shared-object-f">Error while loading shared libraries: &#39;libpcre.so.0: cannot open shared object file: No such file or directory&#39;</a> ) AND to your while script.</p>
<p>but howerver, I was able to fix this by using bash image and modify a little bit your script see the manifest:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  volumes:
    - name: shared
      emptyDir: { }
  containers:
    - name: createfile
      image: bash
      command: [ &quot;/bin/sh&quot;, &quot;-c&quot; ]
      args:
        - while true; do
          touch /usr/test.txt &amp;&amp; ls /usr/ &amp;&amp; echo &quot;new file created on container&quot; &amp;&amp; sleep 10;
          done
      volumeMounts:
        - name: shared
          mountPath: /usr/
    - name: deletefile
      image: bash
      volumeMounts:
        - name: shared
          mountPath: /usr/
      command: [ &quot;/bin/sh&quot;, &quot;-c&quot; ]
      args:
        - while true; do
          rm /usr/test.txt &amp;&amp; ls /usr/ &amp;&amp; echo &quot;container 2 - file removed&quot; &amp;&amp; sleep 10;
          done
</code></pre>
<p>createfile output:</p>
<pre><code>❯ k logs -f mypod -c createfile
test.txt
new file created on container
test.txt
new file created on container
test.txt
new file created on container
test.txt
new file created on container
test.txt
new file created on container
test.txt
new file created on container
test.txt
new file created on container
test.txt
new file created on container
test.txt
new file created on container
test.txt
new file created on container
test.txt
new file created on container
test.txt
new file created on container
test.txt
...
</code></pre>
<p>deletefile output:</p>
<pre><code>❯ k logs -f mypod -c deletefile
container 2 - file removed
container 2 - file removed
container 2 - file removed
container 2 - file removed
container 2 - file removed
container 2 - file removed
container 2 - file removed
container 2 - file removed
container 2 - file removed
container 2 - file removed
container 2 - file removed
container 2 - file removed
container 2 - file removed
container 2 - file removed
container 2 - file removed
container 2 - file removed
...
</code></pre>
