<p>I have docker and kubernetes (enable kubernetes checked on docker settings) installed on my local macbook. I create containers using docker and after my machine restarts, these exactly same containers are still present. However, if I create containers within pods using kubernetes and machine is restarted, then I do see the containers but those are like freshly created containers and not the same containers prior to restart.
What changes do I need to make so that even after machine restart my containers within the pods remain the same same before restart.</p>

Puri
<p>Even at runtime, Kubernetes may move Pods at will (e.g. during scaling, cluster upgrades, adding and removing nodes, etc.).</p>

<p>It is a good idea to try to treat containers as 'cattle, not pets', i.e. don't expect them to be long-lived.</p>

<p>If you need a container to be 'the same' after restart, consider using <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/#introduction" rel="nofollow noreferrer">Persisent Volumes</a> to store their state. Depending on your requirements, <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer">StatefulSets</a> may also be worth considering.</p>

<p>Or consider having them reload / recompute any additional data they need after startup. The mechanism for this will depend on your code.</p>
