Mounting GlusterFS with a Docker Container in Flatcar Linux/CoreOS

Authored by Lachlan Davidson


When building a Docker Swarm cluster in my homelab using Flatcar Linux, I found myself needing to mount a remote GlusterFS volume.

Now, by design, Flatcar Linux doesn't have a packager manager, and is designed to do atomic updates with immutable OS images -- it is designed so that all of your workloads should run in containers.

GlusterFS provide Docker containers for both client and server, however I couldn't find any examples on how to use the client container, so after a bit of poking around, I came up with the following:

sudo -i
mkdir /mnt/gv-swarm
docker run --restart=always -d --name glusterfs-client --mount type=bind,source=/mnt/gv-swarm,target=/mnt/gv-swarm,bind-propagation=rshared --privileged=true gluster/glusterfs-client /bin/bash -c "mount -t glusterfs gluster1.swarm.lan:/gv-swarm /mnt/gv-swarm; sleep infinity"

Now I have my GlusterFS volume mounted in /mnt/gv-swarm and can start using this for persistent, shared storage in my conainers.

That is all :)