<p>I am new to Docker containers and still in the learning phase. I am trying to test the below code in my Kubernetes free account.</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: two-containers
spec:
  restartPolicy: Never
  volumes:
  - name: shared-data
    emptyDir: {}
  containers:
  - name: nginx-container
    image: nginx
    volumeMounts:
    - name: shared-data
      mountPath: /usr/share/nginx/html
  - name: debian-container
    image: debian
    volumeMounts:
    - name: shared-data
      mountPath: /pod-data
    command: ["/bin/sh"]
    args: ["-c", "echo Hello from the debian container &gt; /pod-data/index.html"]
</code></pre>

<p>this part is working fine.</p>

<p>However when I run the Debian container it terminates immediately after writing <code>/pod-data/index.html</code> to shared volume path, and I cannot figure out why this is happening.</p>

<p>Has anyone come across this scenario before, who has a possible solution.</p>

Sushil.R
<pre><code>    command: ["/bin/sh"]
    args: ["-c", "echo Hello from the debian container &gt; /pod-data/index.html"]
</code></pre>

<p>if you look at the debian container, you see that it is writing 'Hello from the debian container' to /pod-data/index.html.</p>

<p>the process is complete and there is nothing more to be done. hence the container gets terminated.</p>

<p>On the other hand, the nginx container runs a daemon process that runs all the time serving the web content to end users and hence it would continue to run.</p>
