Share GlusterFS mount in one container to other container

Hey,

i have one “Gluster-Container”. This container has the glusterfs-client installed and mounts an glusterfs volume to /mnt/storage.

My goal is to share /mnt/storage (with the mounted gluster volume) with other containers. To accomplish this, i tried the following docker-compose file:

php:
    image: php-image
    hostname: php
    volumes:
      - gluster-volume:/mnt/storage

gluster:
    image: gluster-image
    privileged: true
    volumes:
      - /root/fstab:/etc/fstab
      - gluster-volume:/mnt/storage

volumes:
    gluster-volume:

But that didn’t work out.
GlusterFS is already mounted on /mnt/storage. So when docker want to mount a volume to /mnt/storage it will fail. I guess? I don’t know exactly because i don’t get any errors. The shared volume just doesn’t work (items don’t get shared between containers/volume stays empty).

Any ideas/considerations how to solve this problem are welcome!

What i already tried:

Solutions that may work:

  • Install gluster-client in all the other containers (this sucks escpacially because the gluster container needs to be privileged.).
  • Install a SMB-Server and a SMB-Client.

But I am not happy with any of these solutions.

Hello.
Our solution for a similar issue was to create the gluster volume in the docker hosts.
And then bind the gluster mount point to the container with --mount type=bind

In this way we can mount the same mount point in the host to many containers, and it doesn’t matter the host where the container runs, it has access to the same data siince gluster is replicating the data in all docker nodes.

This is also our current solution. But more as a workaround.

Because i think this way has a major drawback: The developers have to install the glusterfs client locally on their machines and have to mount the gluster-volume before they start to work.?

Maybe you can enable the NFS export in the gluster container and use something like that in the clients:

volumes:
XXXVOLUME:
driver: local
driver_opts:
type: “nfs”
o: “addr=IP,hard,proto=tcp,timeo=600,rw,relatime,vers=3,rsize=131072,wsize=131072”
device: “:/volume1”

We are using this config in one service and all replicas are mounting the remote nfs. You will need the nfs-common and nfs-client in the docker hosts

Regards

I created a docker volume plugin for gluster which contains the gluster client in its own container so it does not need to be installed on the host directly. https://hub.docker.com/r/trajano/glusterfs-volume-plugin/ this addresses the issue for the developers slightly (they still need to install the plugin but at least it is contained within the docker ecosystem)

I also found that future versions of docker will allow deploying the plugin into a swarm but that’s not out yet from the CLI perspective.