In many cases, application components need to store some data. This can be very complicated in distributed environments. That is why we usually talk about containers as ephemeral components. Stateless components are easy to implement, but in stateful components, we try to decouple persistent data from a container's filesystems. Remember that data in containers can be lost. In fact, orchestration does not care about data and therefore, if a container dies, it will just run a new one. In these cases, we need to persist data out of a container's environment. We can use what we learned about volume objects in Chapter 4, Container Persistency and Networking, to do this. We defined volumes to bypass a container's filesystem to improve performance and to store data out of the container's life cycle.
In distributed environments, using the host's local storage will leave application components in inconsistent states when they are moved from...