Giter Club home page Giter Club logo

docker-volume-linode's Introduction

Docker Volume Driver For Linode

Build

This volume plugin adds the ability to manage Linode Block Storage as Docker Volumes from within a Linode. 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 Fedora 34, should work with other versions and distributions)
  • Docker (tested on version 20, should work with other versions)

Installation

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

Driver Options

Option Name Description
linode-token Required The Linode APIv4 Personal Access Token to use. (requires linodes:read_write volumes:read_write events:read_only)
linode-label Required The label of the current Linode.
force-attach If true, volumes will be forcibly attached to the current Linode if already attached to another Linode. (defaults to false) WARNING: Forcibly reattaching volumes can result in data loss if a volume is not properly unmounted.
mount-root Sets the root directory for volume mounts (defaults to /mnt)
log-level Sets log level to debug,info,warn,error (defaults to info)
socket-user Sets the user to create the docker socket with (defaults to root)

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

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

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.

Tested On

Fedora 34
Tested With:
Client:
 Version:           20.10.8
 API version:       1.41
 Go version:        go1.16.6
 Git commit:        3967b7d
 Built:             Sun Aug 15 22:43:35 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.8
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.6
  Git commit:       75249d8
  Built:            Sun Aug 15 00:00:00 2021
  OS/Arch:          linux/amd64
  Experimental:     false

Discussion / Help

Join us at #linodego on the gophers slack

docker-volume-linode's People

Contributors

bsdlp avatar displague avatar jriddle-linode avatar lbgarber avatar phillc avatar ricardorg79 avatar riramir-rei avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.