Docker volume plugins (original) (raw)

Docker Engine volume plugins enable Engine deployments to be integrated with external storage systems such as Amazon EBS, and enable data volumes to persist beyond the lifetime of a single Docker host. See theplugin documentation for more information.

1.13.0

1.12.0

1.10.0

1.8.0

To give a container access to a volume, use the --volume and --volume-driverflags on the docker container run command. The --volume (or -v) flag accepts a volume name and path on the host, and the --volume-driver flag accepts a driver type.

--volume

The --volume (or -v) flag takes a value that is in the format<volume_name>:<mountpoint>. The two parts of the value are separated by a colon (:) character.

volumedriver

Specifying a volumedriver in conjunction with a volumename allows you to use plugins such as Flocker to manage volumes external to a single host, such as those on EBS.

The container creation endpoint (/containers/create) accepts a VolumeDriverfield of type string allowing to specify the name of the driver. If not specified, it defaults to "local" (the default driver for local volumes).

If a plugin registers itself as a VolumeDriver when activated, it must provide the Docker Daemon with writeable paths on the host filesystem. The Docker daemon provides these paths to containers to consume. The Docker daemon makes the volumes available by bind-mounting the provided paths into the containers.

Volume plugins should not write data to the /var/lib/docker/ directory, including /var/lib/docker/volumes. The /var/lib/docker/ directory is reserved for Docker.

/VolumeDriver.Create

Request:

Instruct the plugin that the user wants to create a volume, given a user specified volume name. The plugin does not need to actually manifest the volume on the filesystem yet (until Mount is called).Opts is a map of driver specific options passed through from the user request.

Response:

Respond with a string error if an error occurred.

/VolumeDriver.Remove

Request:

Delete the specified volume from disk. This request is issued when a user invokes docker rm -v to remove volumes associated with a container.

Response:

Respond with a string error if an error occurred.

/VolumeDriver.Mount

Request:

Docker requires the plugin to provide a volume, given a user specified volume name. Mount is called once per container start. If the same volume_name is requested more than once, the plugin may need to keep track of each new mount request and provision at the first mount request and deprovision at the last corresponding unmount request.

ID is a unique ID for the caller that is requesting the mount.

Response:

Mountpoint is the path on the host (v1) or in the plugin (v2) where the volume has been made available.

Err is either empty or contains an error string.

/VolumeDriver.Path

Request:

Request the path to the volume with the given volume_name.

Response:

Respond with the path on the host (v1) or inside the plugin (v2) where the volume has been made available, and/or a string error if an error occurred.

Mountpoint is optional. However, the plugin may be queried again later if one is not provided.

/VolumeDriver.Unmount

Request:

Docker is no longer using the named volume. Unmount is called once per container stop. Plugin may deduce that it is safe to deprovision the volume at this point.

ID is a unique ID for the caller that is requesting the mount.

Response:

Respond with a string error if an error occurred.

/VolumeDriver.Get

Request:

Get info about volume_name.

Response:

Respond with a string error if an error occurred. Mountpoint and Status are optional.

/VolumeDriver.List

Request:

Get the list of volumes registered with the plugin.

Response:

Respond with a string error if an error occurred. Mountpoint is optional.

/VolumeDriver.Capabilities

Request:

Get the list of capabilities the driver supports.

The driver is not required to implement Capabilities. If it is not implemented, the default values are used.

Response:

Supported scopes are global and local. Any other value in Scope will be ignored, and local is used. Scope allows cluster managers to handle the volume in different ways. For instance, a scope of global, signals to the cluster manager that it only needs to create the volume once instead of on each Docker host. More capabilities may be added in the future.