github.com/nf/docker@v1.8.1/docs/extend/plugins_volume.md (about) 1 <!--[metadata]> 2 +++ 3 title = "Volume plugins" 4 description = "How to manage data with external volume plugins" 5 keywords = ["Examples, Usage, volume, docker, data, volumes, plugin, api"] 6 [menu.main] 7 parent = "mn_extend" 8 +++ 9 <![end-metadata]--> 10 11 # Write a volume plugin 12 13 Docker volume plugins enable Docker deployments to be integrated with external 14 storage systems, such as Amazon EBS, and enable data volumes to persist beyond 15 the lifetime of a single Docker host. See the [plugin documentation](plugins.md) 16 for more information. 17 18 # Command-line changes 19 20 A volume plugin makes use of the `-v`and `--volume-driver` flag on the `docker run` command. The `-v` flag accepts a volume name and the `--volume-driver` flag a driver type, for example: 21 22 $ docker run -ti -v volumename:/data --volume-driver=flocker busybox sh 23 24 This command passes the `volumename` through to the volume plugin as a 25 user-given name for the volume. The `volumename` must not begin with a `/`. 26 27 By having the user specify a `volumename`, a plugin can associate the volume 28 with an external volume beyond the lifetime of a single container or container 29 host. This can be used, for example, to move a stateful container from one 30 server to another. 31 32 By specifying a `volumedriver` in conjunction with a `volumename`, users can use plugins such as [Flocker](https://clusterhq.com/docker-plugin/) to manage volumes external to a single host, such as those on EBS. 33 34 35 # Create a VolumeDriver 36 37 The container creation endpoint (`/containers/create`) accepts a `VolumeDriver` 38 field of type `string` allowing to specify the name of the driver. It's default 39 value of `"local"` (the default driver for local volumes). 40 41 # Volume plugin protocol 42 43 If a plugin registers itself as a `VolumeDriver` when activated, then it is 44 expected to provide writeable paths on the host filesystem for the Docker 45 daemon to provide to containers to consume. 46 47 The Docker daemon handles bind-mounting the provided paths into user 48 containers. 49 50 ### /VolumeDriver.Create 51 52 **Request**: 53 ``` 54 { 55 "Name": "volume_name" 56 } 57 ``` 58 59 Instruct the plugin that the user wants to create a volume, given a user 60 specified volume name. The plugin does not need to actually manifest the 61 volume on the filesystem yet (until Mount is called). 62 63 **Response**: 64 ``` 65 { 66 "Err": null 67 } 68 ``` 69 70 Respond with a string error if an error occurred. 71 72 ### /VolumeDriver.Remove 73 74 **Request**: 75 ``` 76 { 77 "Name": "volume_name" 78 } 79 ``` 80 81 Create a volume, given a user specified volume name. 82 83 **Response**: 84 ``` 85 { 86 "Err": null 87 } 88 ``` 89 90 Respond with a string error if an error occurred. 91 92 ### /VolumeDriver.Mount 93 94 **Request**: 95 ``` 96 { 97 "Name": "volume_name" 98 } 99 ``` 100 101 Docker requires the plugin to provide a volume, given a user specified volume 102 name. This is called once per container start. 103 104 **Response**: 105 ``` 106 { 107 "Mountpoint": "/path/to/directory/on/host", 108 "Err": null 109 } 110 ``` 111 112 Respond with the path on the host filesystem where the volume has been made 113 available, and/or a string error if an error occurred. 114 115 ### /VolumeDriver.Path 116 117 **Request**: 118 ``` 119 { 120 "Name": "volume_name" 121 } 122 ``` 123 124 Docker needs reminding of the path to the volume on the host. 125 126 **Response**: 127 ``` 128 { 129 "Mountpoint": "/path/to/directory/on/host", 130 "Err": null 131 } 132 ``` 133 134 Respond with the path on the host filesystem where the volume has been made 135 available, and/or a string error if an error occurred. 136 137 ### /VolumeDriver.Unmount 138 139 **Request**: 140 ``` 141 { 142 "Name": "volume_name" 143 } 144 ``` 145 146 Indication that Docker no longer is using the named volume. This is called once 147 per container stop. Plugin may deduce that it is safe to deprovision it at 148 this point. 149 150 **Response**: 151 ``` 152 { 153 "Err": null 154 } 155 ``` 156 157 Respond with a string error if an error occurred. 158