docker.recipes

GlusterFS

advanced

Scalable network filesystem.

Overview

GlusterFS is an open-source, distributed file system designed to scale to petabytes and handle thousands of clients. Originally developed by Gluster Inc. (later acquired by Red Hat), GlusterFS aggregates storage from multiple servers into a single global namespace, providing high availability and fault tolerance through replication and distribution mechanisms. Unlike traditional network-attached storage solutions, GlusterFS operates without metadata servers, using elastic hashing algorithms to locate files across the cluster. This Docker configuration establishes a two-node GlusterFS cluster using the official gluster-centos containers, each running as privileged containers to access low-level storage operations. The setup creates a replicated volume that maintains copies of data across both nodes, ensuring data redundancy and availability even if one node fails. The configuration isolates GlusterFS traffic on a dedicated Docker network while providing persistent storage for configuration files, logs, and the actual data being served. This stack is ideal for organizations requiring scalable, fault-tolerant storage that can grow horizontally by adding more nodes, making it particularly valuable for cloud-native applications, container orchestration platforms, and distributed computing environments where traditional shared storage becomes a bottleneck.

Key Features

  • Elastic hash algorithm eliminates metadata servers and single points of failure
  • Replica 2 configuration ensures data redundancy across both GlusterFS nodes
  • FUSE-based client mounting allows POSIX-compliant file system access
  • Self-healing capabilities automatically recover corrupted or missing files
  • Volume management through native GlusterFS CLI commands for creation and administration
  • Brick-level storage abstraction enables flexible underlying storage configurations
  • Online volume operations support adding and removing storage without downtime
  • Distributed hash table architecture provides linear scalability by adding nodes

Common Use Cases

  • 1Container persistent storage for Kubernetes and Docker Swarm clusters
  • 2Distributed file sharing for development teams working across multiple servers
  • 3Media streaming platforms requiring high-throughput distributed storage
  • 4Backup storage systems with built-in replication across geographic locations
  • 5Web content delivery networks needing synchronized file distribution
  • 6Scientific computing clusters requiring shared datasets across compute nodes
  • 7Home lab environments testing distributed storage before production deployment

Prerequisites

  • Docker host with privileged container support and sufficient storage space
  • At least 4GB RAM per node for optimal GlusterFS performance
  • Understanding of GlusterFS volume types (distribute, replica, stripe)
  • Network connectivity between containers for brick synchronization
  • Basic knowledge of FUSE filesystem mounting and troubleshooting
  • Familiarity with GlusterFS CLI commands for volume management

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 gluster1:
3 image: gluster/gluster-centos:latest
4 container_name: gluster1
5 privileged: true
6 hostname: gluster1
7 volumes:
8 - gluster1_data:/data
9 - gluster1_etc:/etc/glusterfs
10 - gluster1_lib:/var/lib/glusterd
11 - gluster1_log:/var/log/glusterfs
12 networks:
13 - gluster
14
15 gluster2:
16 image: gluster/gluster-centos:latest
17 container_name: gluster2
18 privileged: true
19 hostname: gluster2
20 volumes:
21 - gluster2_data:/data
22 - gluster2_etc:/etc/glusterfs
23 - gluster2_lib:/var/lib/glusterd
24 - gluster2_log:/var/log/glusterfs
25 networks:
26 - gluster
27
28volumes:
29 gluster1_data:
30 gluster1_etc:
31 gluster1_lib:
32 gluster1_log:
33 gluster2_data:
34 gluster2_etc:
35 gluster2_lib:
36 gluster2_log:
37
38networks:
39 gluster:
40 driver: bridge

.env Template

.env
1# Configure volume after containers start

Usage Notes

  1. 1Create volume: gluster volume create vol1 replica 2 gluster1:/data gluster2:/data
  2. 2Start volume: gluster volume start vol1
  3. 3Mount on client: mount -t glusterfs gluster1:/vol1 /mnt

Individual Services(2 services)

Copy individual services to mix and match with your existing compose files.

gluster1
gluster1:
  image: gluster/gluster-centos:latest
  container_name: gluster1
  privileged: true
  hostname: gluster1
  volumes:
    - gluster1_data:/data
    - gluster1_etc:/etc/glusterfs
    - gluster1_lib:/var/lib/glusterd
    - gluster1_log:/var/log/glusterfs
  networks:
    - gluster
gluster2
gluster2:
  image: gluster/gluster-centos:latest
  container_name: gluster2
  privileged: true
  hostname: gluster2
  volumes:
    - gluster2_data:/data
    - gluster2_etc:/etc/glusterfs
    - gluster2_lib:/var/lib/glusterd
    - gluster2_log:/var/log/glusterfs
  networks:
    - gluster

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 gluster1:
5 image: gluster/gluster-centos:latest
6 container_name: gluster1
7 privileged: true
8 hostname: gluster1
9 volumes:
10 - gluster1_data:/data
11 - gluster1_etc:/etc/glusterfs
12 - gluster1_lib:/var/lib/glusterd
13 - gluster1_log:/var/log/glusterfs
14 networks:
15 - gluster
16
17 gluster2:
18 image: gluster/gluster-centos:latest
19 container_name: gluster2
20 privileged: true
21 hostname: gluster2
22 volumes:
23 - gluster2_data:/data
24 - gluster2_etc:/etc/glusterfs
25 - gluster2_lib:/var/lib/glusterd
26 - gluster2_log:/var/log/glusterfs
27 networks:
28 - gluster
29
30volumes:
31 gluster1_data:
32 gluster1_etc:
33 gluster1_lib:
34 gluster1_log:
35 gluster2_data:
36 gluster2_etc:
37 gluster2_lib:
38 gluster2_log:
39
40networks:
41 gluster:
42 driver: bridge
43EOF
44
45# 2. Create the .env file
46cat > .env << 'EOF'
47# Configure volume after containers start
48EOF
49
50# 3. Start the services
51docker compose up -d
52
53# 4. View logs
54docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/glusterfs/run | bash

Troubleshooting

  • Transport endpoint is not connected: Check if glusterd service is running and volumes are started with 'gluster volume status'
  • Peer probe failed: Verify container hostnames resolve correctly and use 'gluster peer probe <hostname>' to establish connections
  • Volume creation fails with brick path error: Ensure /data directory exists and has proper permissions within containers
  • Split-brain condition detected: Use 'gluster volume heal <volume> info split-brain' to identify and resolve conflicting files
  • Mount operation hangs: Verify glusterfs-fuse is installed on client and check network connectivity to GlusterFS nodes
  • Performance degradation on writes: Check replica count and network latency between nodes, consider tuning performance options

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Components

glusterfs

Tags

#glusterfs#distributed#filesystem#scale

Category

Storage & Backup
Ad Space