Skip to content

Use GlusterFS as a backend for docker volume (also as a plugin)

License

Notifications You must be signed in to change notification settings

sapk/docker-volume-gluster

Repository files navigation

docker-volume-gluster License Project Status

GitHub release Go Report Card codecov master : Travis master develop : Travis develop

Use GlusterFS as a backend for docker volume

Status : proof of concept (working)

Use GlusterFS cli in the plugin container so it depend on fuse on the host.

Docker plugin (New & Easy method) Docker Pulls ImageLayers Size

docker plugin install sapk/plugin-gluster
docker volume create --driver sapk/plugin-gluster --opt voluri="<volumeserver>:<volumename>" --name test
docker run -v test:/mnt --rm -ti ubuntu

Create and Mount volume

docker volume create --driver sapk/plugin-gluster --opt voluri="<volumeserver>,<otherserver>,<otheroptionalserver>:<volumename>" --name test
docker run -v test:/mnt --rm -ti ubuntu

Docker-compose

volumes:
  some_vol:
    driver: sapk/plugin-gluster
    driver_opts:
      voluri: "<volumeserver>:<volumename>"

Additionnal docker-plugin config

docker plugin disable sapk/plugin-gluster

docker plugin set sapk/plugin-gluster DEBUG=1 #Activate --verbose
docker plugin set sapk/plugin-gluster MOUNT_UNIQ=1 #Activate --mount-uniq

docker plugin enable sapk/plugin-gluster

Legacy plugin installation

For Docker version 1.12 or below, the managed plugin system is not supported. This also happens if the plugin is not installed via docker plugin install. Docker's new plugin system is the preferred way to add drivers and plugins, where the plugin is just an image downloaded from registry containing the executable and needed configuration files. You can run both legacy and new plugins in Docker versions above 1.12, but be aware that legacy plugins will not show up on docker plugin ls. They will be listed instead under plugins on docker info.

That way, the driver's name will be just gluster (in both the CLI and Compose environments):

Build

make

Start daemon

./docker-volume-gluster daemon
OR in a docker container
docker run -d --device=/dev/fuse:/dev/fuse --cap-add=SYS_ADMIN --cap-add=MKNOD  -v /run/docker/plugins:/run/docker/plugins -v /var/lib/docker-volumes/gluster:/var/lib/docker-volumes/gluster:shared sapk/docker-volume-gluster

For more advance params : ./docker-volume-gluster --help OR ./docker-volume-gluster daemon --help

Run listening volume drive deamon to listen for mount request

Usage:
  docker-volume-gluster daemon [flags]

Flags:
  -h, --help         help for daemon
      --mount-uniq   Set mountpoint based on definition and not the name of volume

Global Flags:
  -b, --basedir string   Mounted volume base directory (default "/var/lib/docker-volumes/gluster")
  -v, --verbose          Turns on verbose logging

Create and Mount volume

docker volume create --driver gluster --opt voluri="<volumeserver>:<volumename>" --name test
docker run -v test:/mnt --rm -ti ubuntu

Performances :

As tested here, this plugin provide same performances as a gluster volume mounted on host via docker bind mount.

Inspired from :