Docker vs Kubernetes

5/28/2020

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.

-- Puri
containers
docker
kubernetes

1 Answer

5/28/2020

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

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

If you need a container to be 'the same' after restart, consider using Persisent Volumes to store their state. Depending on your requirements, StatefulSets may also be worth considering.

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

-- Paul J
Source: StackOverflow