Simple Volume Plugin for Docker
This Docker plugin allows you to use an arbitrary directory for storing volumes. This is commonly used to use an NFS mount shared between all nodes in a Docker Swarm cluster as the backing storage for volumes.
Run build.sh
or build.ps1
to compile the source code and package the result as a Managed Docker Plugin.
These scripts take a version number as an input argument. The source code itself contains no version numbers. Instead version numbers should be determined at build time using GitVersion.
Usage
Install the plugin:
$ docker plugin install --grant-all-permissions --alias data docker.axoom.cloud/docker-volume-simple:1.0.0 ROOT=/mnt/data/ SCOPE=global
/mnt/volumes/
is the directory in the host filesystem to store volumes in. Only subdirectories of /mnt
are allowed.
SCOPE=data
tells Docker that the underlying storage is shared between all nodes in the cluster .
Create a volume and test it:
$ docker volume create -d data myvolume
sharedvolume
$ docker volume ls
DRIVER VOLUME NAME
local 2d75de358a70ba469ac968ee852efd4234b9118b7722ee26a1c5a90dcaea6751
local 842a765a9bb11e234642c933b3dfc702dee32b73e0cf7305239436a145b89017
local 9d72c664cbd20512d4e3d5bb9b39ed11e4a632c386447461d48ed84731e44034
local be9632386a2d396d438c9707e261f86fd9f5e72a7319417901d84041c8f14a4d
local e1496dfe4fa27b39121e4383d1b16a0a7510f0de89f05b336aab3c0deb4dda0e
data myvolume
$ docker run -it -v myvolume:/some/path busybox ls /some/path
Using the plugin in a docker-compose.yml
file might look something like this:
version: '3.0'
services:
myservice:
image: myservice
volumes:
- "myvolume:/some/dir"
volumes:
myvolume:
driver: data