<p>I have a pod which contains two containers. One container is a web application and another store some static data for this web application. </p>

<p>The data here is a set of files which are stored in the folder of this container with name <code>/data</code> and that's only function of the container to store this data and expose them to the web application.</p>

<p>I'm looking for the way to share the content of this folder with web application container in this pod.</p>

<p>If I'm using the YAML spec below the folder in both containers is empty. Is there a way to share the data from container folder without cleaning it up?</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: my-pod
  labels:
    app: my-app
    version: 1.2.3
spec:
  volumes:
    - name: my-app-data-volume

  containers:
    - name: my-app-server
      image: my-app-server-container-name
      volumeMounts:
        - name: my-app-data-volume
          mountPath: /data
      ports:
        - containerPort: 8080

    - name: my-app-data
      image: my-app-data-container-name
      volumeMounts:
        - name: my-app-data-volume
          mountPath: /data
</code></pre>

<p>You can use an <a href="https://kubernetes.io/docs/concepts/storage/volumes/#emptydir" rel="noreferrer">EmptyDir</a> volume for this. Specify the container that contains the files as an <code>initContainer</code>, then copy the files into the EmptyDir volume. Finally, mount that volume in the web app container.</p>
