Search code examples
dockerdocker-swarmglusterfs

Persisting data in a docker swarm with glusterfs


I have a docker swarm with a lot of containers, but in particolar:

  • mysql
  • mongodb
  • fluentd
  • elasticsearch

My problem is that when a node fails, the manager discards the current container and creates a new one in another node. So everytime i lost the persisting data stored in that particular container even using docker volumes.

So i would create four distributed glusterfs volumes over my cluster, and mount them as docker volumes into my containers.

Is this a correct way to resolve my problem?

If it is, what type of filesystem should i use for my glusterfs volumes?

Are there perfomance problems with this approch?


Solution

  • You might want to take a look at flocker (a volume data manager) which has integration for several container cluster managers, including Docker Swarm.

    You will have to create a volume using flocker driver for each application as pointed by the tutorial:

    ...
    volumes:
      mysql:
        driver: "flocker"
        driver_opts:
          size: "10GiB"
          profile: "bronze"
     ...