We need to find a way to retain state outside containers that run our services.
We could mount a volume on the host. That would allow us to preserve state if a container fails and is rescheduled on the same node. The problem is that such a solution is too limited. There is no guarantee that Swarm will reschedule the service to the same node unless we constrain it. If we would do something like that, we'd prevent Swarm from ensuring service availability. When that node would fail (every node fails sooner or later), Swarm could not reschedule the service. We would be fault tolerant only as long as our servers are running.
We can solve the problem of a node failure by mounting a NFS to each of the servers. That way, every server would have access to the same data, and we could mount a Docker volume to it.
We'll use Amazon Elastic File System (EFS) (https...