Docker Volume Plugin for accessing Hetzner Cloud Volumes
This plugin manages docker volumes using Hetzner Cloud's volumes.
This plugin is still in ALPHA; use at your own risk
To install the plugin, run the following command:
$ docker plugin install --alias hetzner ghcr.io/costela/docker-volume-hetzner:...-amd64
When using Docker Swarm, this should be done on all nodes in the cluster.
Important: the plugin expects the Docker node's hostname
to match with the name of the server created on Hetzner Cloud. This should usually be the case, unless explicitly changed.
During installation, you will be prompted to accept the plugins's privilege requirements. The following are required:
mount
and chown
First, create an API key from the Hetzner Cloud console and save it temporarily.
Install the plugin as described above. Then, set the API key in the plugin options, where <apikey>
is the key you just created:
$ docker plugin disable hetzner
$ docker plugin set hetzner apikey=<apikey>
$ docker plugin enable hetzner
Again, when using Docker Swarm, this should be done on all nodes in the cluster.
The plugin is then ready to be used, e.g. in a docker-compose
file, by setting the driver
option on the docker volume
definition (assuming the alias hetzner
passed during installation above).
For example, when using the following docker-compose
volume definition in a project called foo
:
volumes:
somevolume:
driver: hetzner
This will initialize a Hetzner volume named docker-foo_somevolume
(see the prefix
configuration below).
If the volume docker-foo_somevolume
does not exist in the Hetzner Cloud project, the plugin will do the following:
fstype
option; see below)chown
the volume to the appropriate uid
/gid
if specified.The plugin will then mount the volume on the node running its parent service, if any.
The following options can be passed to the plugin via docker plugin set
(all names case-sensitive):
apikey
(required): authentication token to use when accessing the Hetzner Cloud APIsize
(optional): size of the volume in GB (default: 10
)fstype
(optional): filesystem type to be created on new volumes. Currently supported values are ext{2,3,4}
and xfs
(default: ext4
)prefix
(optional): prefix to use when naming created volumes; the final name on the HC side will be of the form prefix-name
, where name
is the volume name assigned by docker
(default: docker
)loglevel
(optional): the amount of information that will be output by the plugin. Accepts any value supported by logrus (i.e.: fatal
, error
, warn
, info
and debug
; default: warn
)use_protection
(optional): whether to enable/disable deletion protection on creation/deletion. Disable this if you want to manage deletion protection yourself. (default: true
)uid
(optional): which user id to use by default as owners for the filesystem of newly created volumesgid
(optional): which group id to use by default as owners for the filesystem of newly created volumesAdditionally, size
, fstype
, uid
and gid
can also be passed as options to the driver via driver_opts
:
volumes:
somevolume:
driver: hetzner
driver_opts:
size: '42'
fstype: xfs
uid: '999'
gid: '999'
:warning: Passing any option besides size
, fstype
, uid
and gid
to the volume definition will have no effect beyond a warning in the logs. Use docker plugin set
instead.
size
option is currently ignored. This may be worked around in a future release.