Does Docker Swarm keep data synced among nodes?

3/11/2020

I've never done anything with Docker Swarm, or Kubernetes so I'm trying to learn what does what, and which is best for my purpose before tackling it.

My scenario:

  • I have a Desktop PC running Docker Desktop, and ..
  • I have a Raspberry PI running Docker on Raspbian

This is all on a home LAN, so I don't really want to get crazy with complicated things.

I want to run Pi Hole and DNSCrypt Proxy containers on both 'machines', (as redundancy, mostly because the Docker Desktop seems to crash a lot taking down my entire DNS system with it when I just use that machine for Pi-hole).

My main thing is, I want all the data/configurations, etc. between them to stay in sync (i.e. Pi hole's container data stays in sync on both devices, etc.), and I want the manager to make sure it's always up, in case of crashes, and so on.

My questions:

Being completely new to this area, and just doing a bit of poking around:

  • it seems that Kubernetes might be a bit much, and more complicated than I need for this?
  • That's why I was thinking Swarm instead, but I'm also not sure whether either of them will keep data synced?
  • And, say I create 2 Pi-hole containers on the Manager machine, does it create 1 on the manager machine, and 1 on the worker machine?

Any info is appreciated!

-- J. Scott Elblein
docker
docker-swarm
kubernetes

1 Answer

3/17/2020

Docker doesn't quite have anything that directly meets your need, but if you've got a reliable file server on your home LAN, you could do it really easily.

Broadly speaking you want to look at Docker Volume Plugins. Most of them ultimately work via an external storage provider and so won't be that helpful for you. There's a couple of more exotic ones like Portworx or StorageOS that can do portable/replicated storage purely in Docker, but I think most of them are a paid license.

But, if you have a fileserver that you trust to stay up and running, you can mount an NFS/CIFS share as a volume as mentioned in the Docker Docs, and Docker can handle re-connecting it when a container moves from one node to another due to a failure.

One other note: you want two manager nodes and one container per service in your swarm. You need to have one working Manager node for the swarm to work (this is important if a Manager crashes). Multiple separate instances would generally only be helpful if the service was designed as a distributed/fault tolerant application.

-- CantankerousBullMoose
Source: StackOverflow