Skip to content
Docker Volume driver for Linode Block Storage
Go Makefile Dockerfile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.travis.yml switch to go mod and latest linodego Feb 23, 2019
Dockerfile
Makefile
README.md
config.json
driver.go
fs_utils_linux.go
go.mod
go.sum
main.go
utils.go switch to go mod and latest linodego Feb 23, 2019

README.md

Docker Volume Driver For Linode

GoDoc Go Report Card Build Status

This volume plugin adds the ability to manage Linode Block Storage as Docker Volumes. Good use cases for volumes include off-node storage to avoid size constraints or moving a container and the related volume between nodes in a Swarm.

Requirements

  • Linux (tested on Ubuntu 18.04, should work with other versions and distributions)
  • Docker (tested on version 17, should work with other versions)

Installation

When the system hostname is the Linode label, the only required parameter is the linode-token:

docker plugin install --alias linode --grant-all-permissions linode/docker-volume-linode linode-token=<linode token>

Changing the plugin configuration

The plugin can also be configured (or reconfigured) in multiple steps.

docker plugin install --alias linode linode/docker-volume-linode
docker plugin disable linode
docker plugin set linode linode-token=<linode token>
docker plugin set linode linode-label=<linode label>
docker plugin enable linode

Docker Swarm

Volumes can be mounted to one container at the time because Linux Block Storage volumes can only be attached to one Linode at the time.

Usage

All examples assume the driver has been aliased to linode.

Create Volume

Linode Block Storage volumes can be created and managed using the docker volume create command.

$ docker volume create -d linode my-test-volume
my-test-volume

If a named volume already exists on the Linode account and it is in the same region of the Linode, it will be reattached if possible. A Linode Volume can be attached to a single Linode at a time.

Create Options

The driver offers driver specific volume create options:

Option Type Default Description
size int 10 the size (in GB) of the volume to be created. Volumes must be at least 10GB in size, so the default is 10GB.
filesystem string ext4 the filesystem argument for mkfs when formating the new (raw) volume (xfs, btrfs, ext4)
delete-on-remove bool false if the Linode volume should be deleted when removed
$ docker volume create -o size=50 -d linode my-test-volume-50
my-test-volume-50

Volumes can also be created and attached from docker run:

docker run -it --rm --mount volume-driver=linode,source=test-vol,destination=/test,volume-opt=size=25 alpine

Multiple create options can be supplied:

docker run -it --rm --mount volume-driver=linode,source=test-vol,destination=/test,volume-opt=size=25,volume-opt=filesystem=btrfs,volume-opt=delete-on-remove=true alpine

List Volumes

$ docker volume ls
DRIVER              VOLUME NAME
linode:latest       my-test-volume
linode:latest       my-test-volume-50

Use Volume

$ docker run --rm -it -v my-test-volume:/usr/local/apache2/htdocs/ httpd
...

Remove Volumes

$ docker volume rm my-test-volume
my-test-volume

$ docker volume rm my-test-volume-50
my-test-volume-50

Driver Options

Option Name Description
linode-token Required The Linode APIv4 Personal Access Token
linode-label The Linode Label to attach block storage volumes to (defaults to the system hostname)
socket-file Sets the socket file/address (defaults to /run/docker/plugins/linode.sock)
socket-gid Sets the socket GID (defaults to 0)
mount-root Sets the root directory for volume mounts (default /mnt)
log-level Sets log level to debug,info,warn,error (defaults to info)

Options can be set once for all future uses with docker plugin set.

Manual Installation

  • Install Golang: https://golang.org/
  • Get code and Compile: go get -u github.com/linode/docker-volume-linode

Run the driver

docker-volume-linode --linode-token=<token from linode console> --linode-label=<linode label>

Debugging

Enable Debug Level on plugin

The driver name when running manually is the same name as the socket file.

docker plugin set docker-volume-linode LOG_LEVEL=debug

Enable Debug Level in manual installation

docker-volume-linode --linode-token=<...> --linode-label=<...> --log-level=debug

Development

A great place to get started is the [Docker Engine managed plugin system] documentation](https://docs.docker.com/engine/extend/#create-a-volumedriver).

Tested On

Ubuntu 18.04 LTS
Tested With:
Client:
 Version:       17.12.1-ce
 API version:   1.35
 Go version:    go1.10.1
 Git commit:    7390fc6
 Built: Wed Apr 18 01:23:11 2018
 OS/Arch:       linux/amd64

Server:
 Engine:
  Version:      17.12.1-ce
  API version:  1.35 (minimum version 1.12)
  Go version:   go1.10.1
  Git commit:   7390fc6
  Built:        Wed Feb 28 17:46:05 2018
  OS/Arch:      linux/amd64
  Experimental: false

Discussion / Help

Join us at #linodego on the gophers slack

You can’t perform that action at this time.