Browse code

Merge pull request #30524 from mstanleyjones/30149_update_plugin_apidocs

Update plugin_volume apidocs for v2
(cherry picked from commit 3dc87714d1bfcaf0620fabec3bfea89620b59337)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2017/02/15 08:27:04
Showing 1 changed files
... ...
@@ -16,67 +16,86 @@ keywords: "Examples, Usage, volume, docker, data, volumes, plugin, api"
16 16
 # Write a volume plugin
17 17
 
18 18
 Docker Engine volume plugins enable Engine deployments to be integrated with
19
-external storage systems, such as Amazon EBS, and enable data volumes to persist
20
-beyond the lifetime of a single Engine host. See the
19
+external storage systems such as Amazon EBS, and enable data volumes to persist
20
+beyond the lifetime of a single Docker host. See the
21 21
 [plugin documentation](legacy_plugins.md) for more information.
22 22
 
23 23
 ## Changelog
24 24
 
25 25
 ### 1.13.0
26 26
 
27
-- If used as part of the v2 plugin architecture, mountpoints that are part of paths returned by plugin have to be mounted under the directory specified by PropagatedMount in the plugin configuration [#26398](https://github.com/docker/docker/pull/26398)
27
+- If used as part of the v2 plugin architecture, mountpoints that are part of
28
+  paths returned by the plugin must be mounted under the directory specified by
29
+  `PropagatedMount` in the plugin configuration
30
+  ([#26398](https://github.com/docker/docker/pull/26398))
28 31
 
29 32
 ### 1.12.0
30 33
 
31
-- Add `Status` field to `VolumeDriver.Get` response ([#21006](https://github.com/docker/docker/pull/21006#))
32
-- Add `VolumeDriver.Capabilities` to get capabilities of the volume driver([#22077](https://github.com/docker/docker/pull/22077))
34
+- Add `Status` field to `VolumeDriver.Get` response
35
+  ([#21006](https://github.com/docker/docker/pull/21006#))
36
+- Add `VolumeDriver.Capabilities` to get capabilities of the volume driver
37
+  ([#22077](https://github.com/docker/docker/pull/22077))
33 38
 
34 39
 ### 1.10.0
35 40
 
36
-- Add `VolumeDriver.Get` which gets the details about the volume ([#16534](https://github.com/docker/docker/pull/16534))
37
-- Add `VolumeDriver.List` which lists all volumes owned by the driver ([#16534](https://github.com/docker/docker/pull/16534))
41
+- Add `VolumeDriver.Get` which gets the details about the volume
42
+  ([#16534](https://github.com/docker/docker/pull/16534))
43
+- Add `VolumeDriver.List` which lists all volumes owned by the driver
44
+  ([#16534](https://github.com/docker/docker/pull/16534))
38 45
 
39 46
 ### 1.8.0
40 47
 
41
-- Initial support for volume driver plugins ([#14659](https://github.com/docker/docker/pull/14659))
48
+- Initial support for volume driver plugins
49
+  ([#14659](https://github.com/docker/docker/pull/14659))
42 50
 
43 51
 ## Command-line changes
44 52
 
45
-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:
53
+To give a container access to a volume, use the `--volume` and `--volume-driver`
54
+flags on the `docker container run` command.  The `--volume` (or `-v`) flag
55
+accepts a volume name and path on the host, and the `--volume-driver` flag
56
+accepts a driver type.
46 57
 
47
-    $ docker run -ti -v volumename:/data --volume-driver=flocker   busybox sh
58
+```bash
59
+$ docker volume create --driver=flocker volumename
48 60
 
49
-This command passes the `volumename` through to the volume plugin as a
50
-user-given name for the volume. The `volumename` must not begin with a `/`.
61
+$ docker container run -it --volume volumename:/data busybox sh
62
+```
63
+
64
+### `--volume`
51 65
 
52
-By having the user specify a  `volumename`, a plugin can associate the volume
53
-with an external volume beyond the lifetime of a single container or container
54
-host. This can be used, for example, to move a stateful container from one
55
-server to another.
66
+The `--volume` (or `-v`) flag takes a value that is in the format
67
+`<volume_name>:<mountpoint>`. The two parts of the value are
68
+separated by a colon (`:`) character.
56 69
 
57
-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.
70
+- The volume name is a human-readable name for the volume, and cannot begin with
71
+  a `/` character. It is referred to as `volume_name` in the rest of this topic.
72
+- The `Mountpoint` is the path on the host (v1) or in the plugin (v2) where the
73
+  volume has been made available.
58 74
 
75
+### `volumedriver`
76
+
77
+Specifying a `volumedriver` in conjunction with a `volumename` allows you to
78
+use plugins such as [Flocker](https://github.com/ScatterHQ/flocker) to manage
79
+volumes external to a single host, such as those on EBS.
59 80
 
60 81
 ## Create a VolumeDriver
61 82
 
62 83
 The container creation endpoint (`/containers/create`) accepts a `VolumeDriver`
63
-field of type `string` allowing to specify the name of the driver. It's default
64
-value of `"local"` (the default driver for local volumes).
84
+field of type `string` allowing to specify the name of the driver. If not
85
+specified, it defaults to `"local"` (the default driver for local volumes).
65 86
 
66 87
 ## Volume plugin protocol
67 88
 
68
-If a plugin registers itself as a `VolumeDriver` when activated, then it is
69
-expected to provide writeable paths on the host filesystem for the Docker
70
-daemon to provide to containers to consume.
71
-
72
-The Docker daemon handles bind-mounting the provided paths into user
73
-containers.
89
+If a plugin registers itself as a `VolumeDriver` when activated, it must
90
+provide the Docker Daemon with writeable paths on the host filesystem. The Docker
91
+daemon provides these paths to containers to consume. The Docker daemon makes
92
+the volumes available by bind-mounting the provided paths into the containers.
74 93
 
75 94
 > **Note**: Volume plugins should *not* write data to the `/var/lib/docker/`
76 95
 > directory, including `/var/lib/docker/volumes`. The `/var/lib/docker/`
77 96
 > directory is reserved for Docker.
78 97
 
79
-### /VolumeDriver.Create
98
+### `/VolumeDriver.Create`
80 99
 
81 100
 **Request**:
82 101
 ```json
... ...
@@ -87,9 +106,9 @@ containers.
87 87
 ```
88 88
 
89 89
 Instruct the plugin that the user wants to create a volume, given a user
90
-specified volume name.  The plugin does not need to actually manifest the
91
-volume on the filesystem yet (until Mount is called).
92
-Opts is a map of driver specific options passed through from the user request.
90
+specified volume name. The plugin does not need to actually manifest the
91
+volume on the filesystem yet (until `Mount` is called).
92
+`Opts` is a map of driver specific options passed through from the user request.
93 93
 
94 94
 **Response**:
95 95
 ```json
... ...
@@ -100,7 +119,7 @@ Opts is a map of driver specific options passed through from the user request.
100 100
 
101 101
 Respond with a string error if an error occurred.
102 102
 
103
-### /VolumeDriver.Remove
103
+### `/VolumeDriver.Remove`
104 104
 
105 105
 **Request**:
106 106
 ```json
... ...
@@ -109,7 +128,8 @@ Respond with a string error if an error occurred.
109 109
 }
110 110
 ```
111 111
 
112
-Delete the specified volume from disk. This request is issued when a user invokes `docker rm -v` to remove volumes associated with a container.
112
+Delete the specified volume from disk. This request is issued when a user
113
+invokes `docker rm -v` to remove volumes associated with a container.
113 114
 
114 115
 **Response**:
115 116
 ```json
... ...
@@ -120,7 +140,7 @@ Delete the specified volume from disk. This request is issued when a user invoke
120 120
 
121 121
 Respond with a string error if an error occurred.
122 122
 
123
-### /VolumeDriver.Mount
123
+### `/VolumeDriver.Mount`
124 124
 
125 125
 **Request**:
126 126
 ```json
... ...
@@ -131,47 +151,76 @@ Respond with a string error if an error occurred.
131 131
 ```
132 132
 
133 133
 Docker requires the plugin to provide a volume, given a user specified volume
134
-name. This is called once per container start. If the same volume_name is requested
134
+name. `Mount` is called once per container start. If the same `volume_name` is requested
135 135
 more than once, the plugin may need to keep track of each new mount request and provision
136 136
 at the first mount request and deprovision at the last corresponding unmount request.
137 137
 
138 138
 `ID` is a unique ID for the caller that is requesting the mount.
139 139
 
140 140
 **Response**:
141
-```json
142
-{
143
-    "Mountpoint": "/path/to/directory/on/host",
144
-    "Err": ""
145
-}
146
-```
147 141
 
148
-Respond with the path on the host filesystem where the volume has been made
149
-available, and/or a string error if an error occurred.
142
+- **v1**:
143
+
144
+  ```json
145
+  {
146
+      "Mountpoint": "/path/to/directory/on/host",
147
+      "Err": ""
148
+  }
149
+  ```
150
+
151
+- **v2**:
152
+
153
+  ```json
154
+  {
155
+      "Mountpoint": "/path/under/PropagatedMount",
156
+      "Err": ""
157
+  }
158
+  ```
159
+
160
+`Mountpoint` is the path on the host (v1) or in the plugin (v2) where the volume
161
+has been made available.
150 162
 
151
-### /VolumeDriver.Path
163
+`Err` is either empty or contains an error string.
164
+
165
+### `/VolumeDriver.Path`
152 166
 
153 167
 **Request**:
168
+
154 169
 ```json
155 170
 {
156 171
     "Name": "volume_name"
157 172
 }
158 173
 ```
159 174
 
160
-Docker needs reminding of the path to the volume on the host.
175
+Request the path to the volume with the given `volume_name`.
161 176
 
162 177
 **Response**:
163
-```json
164
-{
165
-    "Mountpoint": "/path/to/directory/on/host",
166
-    "Err": ""
167
-}
168
-```
169 178
 
170
-Respond with the path on the host filesystem where the volume has been made
171
-available, and/or a string error if an error occurred. `Mountpoint` is optional,
172
-however, the plugin may be queried again later if one is not provided.
179
+- **v1**:
180
+
181
+  ```json
182
+  {
183
+      "Mountpoin": "/path/to/directory/on/host",
184
+      "Err": ""
185
+  }
186
+  ```
187
+
188
+- **v2**:
189
+
190
+  ```json
191
+  {
192
+      "Mountpoint": "/path/under/PropagatedMount",
193
+      "Err": ""
194
+  }
195
+  ```
196
+
197
+Respond with the path on the host (v1) or inside the plugin (v2) where the
198
+volume has been made available, and/or a string error if an error occurred.
199
+
200
+`Mountpoint` is optional. However, the plugin may be queried again later if one
201
+is not provided.
173 202
 
174
-### /VolumeDriver.Unmount
203
+### `/VolumeDriver.Unmount`
175 204
 
176 205
 **Request**:
177 206
 ```json
... ...
@@ -181,8 +230,8 @@ however, the plugin may be queried again later if one is not provided.
181 181
 }
182 182
 ```
183 183
 
184
-Indication that Docker no longer is using the named volume. This is called once
185
-per container stop.  Plugin may deduce that it is safe to deprovision it at
184
+Docker is no longer using the named volume. `Unmount` is called once per
185
+container stop. Plugin may deduce that it is safe to deprovision the volume at
186 186
 this point.
187 187
 
188 188
 `ID` is a unique ID for the caller that is requesting the mount.
... ...
@@ -197,7 +246,7 @@ this point.
197 197
 Respond with a string error if an error occurred.
198 198
 
199 199
 
200
-### /VolumeDriver.Get
200
+### `/VolumeDriver.Get`
201 201
 
202 202
 **Request**:
203 203
 ```json
... ...
@@ -206,20 +255,36 @@ Respond with a string error if an error occurred.
206 206
 }
207 207
 ```
208 208
 
209
-Get the volume info.
209
+Get info about `volume_name`.
210 210
 
211 211
 
212 212
 **Response**:
213
-```json
214
-{
215
-  "Volume": {
216
-    "Name": "volume_name",
217
-    "Mountpoint": "/path/to/directory/on/host",
218
-    "Status": {}
219
-  },
220
-  "Err": ""
221
-}
222
-```
213
+
214
+- **v1**:
215
+
216
+  ```json
217
+  {
218
+    "Volume": {
219
+      "Name": "volume_name",
220
+      "Mountpoint": "/path/to/directory/on/host",
221
+      "Status": {}
222
+    },
223
+    "Err": ""
224
+  }
225
+  ```
226
+
227
+- **v2**:
228
+
229
+  ```json
230
+  {
231
+    "Volume": {
232
+      "Name": "volume_name",
233
+      "Mountpoint": "/path/under/PropagatedMount",
234
+      "Status": {}
235
+    },
236
+    "Err": ""
237
+  }
238
+  ```
223 239
 
224 240
 Respond with a string error if an error occurred. `Mountpoint` and `Status` are
225 241
 optional.
... ...
@@ -235,17 +300,35 @@ optional.
235 235
 Get the list of volumes registered with the plugin.
236 236
 
237 237
 **Response**:
238
-```json
239
-{
240
-  "Volumes": [
241
-    {
242
-      "Name": "volume_name",
243
-      "Mountpoint": "/path/to/directory/on/host"
244
-    }
245
-  ],
246
-  "Err": ""
247
-}
248
-```
238
+
239
+- **v1**:
240
+
241
+  ```json
242
+  {
243
+    "Volumes": [
244
+      {
245
+        "Name": "volume_name",
246
+        "Mountpoint": "/path/to/directory/on/host"
247
+      }
248
+    ],
249
+    "Err": ""
250
+  }
251
+  ```
252
+
253
+- **v2**:
254
+
255
+  ```json
256
+  {
257
+    "Volumes": [
258
+      {
259
+        "Name": "volume_name",
260
+        "Mountpoint": "/path/under/PropagatedMount"
261
+      }
262
+    ],
263
+    "Err": ""
264
+  }
265
+  ```
266
+
249 267
 
250 268
 Respond with a string error if an error occurred. `Mountpoint` is optional.
251 269
 
... ...
@@ -257,8 +340,9 @@ Respond with a string error if an error occurred. `Mountpoint` is optional.
257 257
 ```
258 258
 
259 259
 Get the list of capabilities the driver supports.
260
-The driver is not required to implement this endpoint, however, in such cases
261
-the default values will be taken.
260
+
261
+The driver is not required to implement `Capabilities`. If it is not
262
+implemented, the default values are used.
262 263
 
263 264
 **Response**:
264 265
 ```json
... ...
@@ -270,7 +354,7 @@ the default values will be taken.
270 270
 ```
271 271
 
272 272
 Supported scopes are `global` and `local`. Any other value in `Scope` will be
273
-ignored and assumed to be `local`. Scope allows cluster managers to handle the
274
-volume differently, for instance with a scope of `global`, the cluster manager
275
-knows it only needs to create the volume once instead of on every engine. More
276
-capabilities may be added in the future.
273
+ignored, and `local` is used. `Scope` allows cluster managers to handle the
274
+volume in different ways. For instance, a scope of `global`, signals to the
275
+cluster manager that it only needs to create the volume once instead of on each
276
+Docker host. More capabilities may be added in the future.