0

Coming from a VMware environment, my through process was that,

  1. Multiple Docker machines (swarm), mount the same NFS data stores
  2. A container (e.g. Maria dB) is deployed on the Docker swarm
  3. If a node in the swarm fails, the service is still running on the other nodes

So I mounted /var/lib/docker/volumes on an NFS share, on multiple Docker machines and tried to create a swarm. But eventually I found out that if multiple Docker machines mount the same NFS data store, the Docker service can only be started on one of the nodes.

So I guess my question is, how to I create a swarm, with the same service running on multiple nodes, and the data is kept on an NFS share?

Of course there’s a good chance I haven’t yet completely understood the idea of how a Docker swarm works, and I’m looking at this from a wrong angle.

2
  • Docker doesn't by itself. This is why things like Kubernetes and OpenShift exist. – Michael Hampton Mar 16 '18 at 15:34
  • to the best of my knowledge, kubernetes replaces the docker swarm, and orchestrates it. So shouldn't Docker swarm provide high availability? – aristosv Mar 16 '18 at 15:37
0

Correct you don't want to share anything in /var/lib/docker, which is data and configs for that engine on a single server.

In a swarm, you add nodes to the swarm, as managers or workers, and the managers replicate the raft consensus db that stores the swarm config and state.

You then create services, that have one or more replicas of the same container image, launched on various nodes based on requirements and availability.

For databases, you're dealing with persistent data (the db's and logs of each db instance). That has to do with Docker Volumes (where you store persistent data), and specifically which volume driver you choose. The default just stores the volume for that service replica (container) on the node it's currently running on. If you want that database container to be able to fail and spin up on a new node automatically (one of the features of a container orchestrator) you need to use a different volume driver that is "swarm aware" and knows how to make sure that NFS mount is placed on the correct node to be ready for the correct service replica.

You can check out REX-Ray which acts as a middle layer for managing the volumes on external storage (and has its own drivers for the type of backend) or look at the full list in the Docker Store.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.