I've been reasearching docker swarms and found out that a swarm is a collection of nodes, nodes are computers that run services, services are schedulers of tasks, and tasks are running containers. Services are made out of a single container image and can be made out of multiple redundant tasks.
My question is: if tasks are instances of container images, how is memory and storage shared between them, assuming your service is running a stateful application like a database (storage) or a website backend (memory)?
- Are the resource requirements multiplied and sinchronized regularly or in real-time? By that logic shouldn't there be a "master task"?
- If not, then stateful applications should have at maximum 1 task replica per service, and each redundancy unit should be a new actively mantained service (like databases, for instance)?
The core of my question is that I assume that services are general-purpose, so most types of applications could benefit from this task replication thing. Otherwise, isn't this core feature only suitable for stateless applications like rest apis? I imagine core features of general-purpose tools to also be general-purpose.