<p>I have ran a docker container locally and it stores data in a file (currently no volume is mounted). I stored some data using the API. After that I failed the container using <code>process.exit(1)</code> and started the container again. The previously stored data in the container survives (as expected). But when I do this same thing in Kubernetes (minikube) the data is lost.</p>

karan525
<p>Posting this as a community wiki for better visibility, feel free to edit and expand it.</p>
<p>As described in comments, kubernetes replaces failed containers with new (identical) ones and this explain why container's filesystem will be clean.</p>
<p>Also as said containers should be stateless. There are different options how to run different applications and take care about its data:</p>
<ul>
<li><a href="https://kubernetes.io/docs/tasks/run-application/run-stateless-application-deployment/" rel="nofollow noreferrer">Run a stateless application using a Deployment</a></li>
<li>Run a stateful application either as a <a href="https://kubernetes.io/docs/tasks/run-application/run-single-instance-stateful-application/" rel="nofollow noreferrer">single instance</a> or as a <a href="https://kubernetes.io/docs/tasks/run-application/run-replicated-stateful-application/" rel="nofollow noreferrer">replicated set</a></li>
<li><a href="https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/" rel="nofollow noreferrer">Run automated tasks with a CronJob</a></li>
</ul>
<p>Useful links:</p>
<ul>
<li><a href="https://kubernetes.io/docs/concepts/workloads/" rel="nofollow noreferrer">Kubernetes workloads</a></li>
<li><a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/" rel="nofollow noreferrer">Pod lifecycle</a></li>
</ul>
