github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/cli/docs/extend/plugins_graphdriver.md (about) 1 --- 2 description: "How to manage image and container filesystems with external plugins" 3 keywords: "Examples, Usage, storage, image, docker, data, graph, plugin, api" 4 advisory: experimental 5 --- 6 7 <!-- This file is maintained within the docker/cli GitHub 8 repository at https://github.com/docker/cli/. Make all 9 pull requests against that repo. If you see this file in 10 another repository, consider it read-only there, as it will 11 periodically be overwritten by the definitive file. Pull 12 requests which include edits to this file in other repositories 13 will be rejected. 14 --> 15 16 # Graphdriver plugins 17 18 ## Changelog 19 20 ### 1.13.0 21 22 - Support v2 plugins 23 24 # Docker graph driver plugins 25 26 Docker graph driver plugins enable admins to use an external/out-of-process 27 graph driver for use with Docker engine. This is an alternative to using the 28 built-in storage drivers, such as aufs/overlay/devicemapper/btrfs. 29 30 You need to install and enable the plugin and then restart the Docker daemon 31 before using the plugin. See the following example for the correct ordering 32 of steps. 33 34 ``` 35 $ docker plugin install cpuguy83/docker-overlay2-graphdriver-plugin # this command also enables the driver 36 <output suppressed> 37 $ pkill dockerd 38 $ dockerd --experimental -s cpuguy83/docker-overlay2-graphdriver-plugin 39 ``` 40 41 # Write a graph driver plugin 42 43 See the [plugin documentation](https://docs.docker.com/engine/extend/) for detailed information 44 on the underlying plugin protocol. 45 46 47 ## Graph Driver plugin protocol 48 49 If a plugin registers itself as a `GraphDriver` when activated, then it is 50 expected to provide the rootfs for containers as well as image layer storage. 51 52 ### /GraphDriver.Init 53 54 **Request**: 55 ```json 56 { 57 "Home": "/graph/home/path", 58 "Opts": [], 59 "UIDMaps": [], 60 "GIDMaps": [] 61 } 62 ``` 63 64 Initialize the graph driver plugin with a home directory and array of options. 65 These are passed through from the user, but the plugin is not required to parse 66 or honor them. 67 68 The request also includes a list of UID and GID mappings, structed as follows: 69 ```json 70 { 71 "ContainerID": 0, 72 "HostID": 0, 73 "Size": 0 74 } 75 ``` 76 77 **Response**: 78 ```json 79 { 80 "Err": "" 81 } 82 ``` 83 84 Respond with a non-empty string error if an error occurred. 85 86 87 ### /GraphDriver.Capabilities 88 89 **Request**: 90 ```json 91 {} 92 ``` 93 94 Get behavioral characteristics of the graph driver. If a plugin does not handle 95 this request, the engine will use default values for all capabilities. 96 97 **Response**: 98 ```json 99 { 100 "ReproducesExactDiffs": false, 101 } 102 ``` 103 104 Respond with values of capabilities: 105 106 * **ReproducesExactDiffs** Defaults to false. Flags that this driver is capable 107 of reproducing exactly equivalent diffs for read-only filesystem layers. 108 109 110 ### /GraphDriver.Create 111 112 **Request**: 113 ```json 114 { 115 "ID": "46fe8644f2572fd1e505364f7581e0c9dbc7f14640bd1fb6ce97714fb6fc5187", 116 "Parent": "2cd9c322cb78a55e8212aa3ea8425a4180236d7106938ec921d0935a4b8ca142", 117 "MountLabel": "", 118 "StorageOpt": {} 119 } 120 ``` 121 122 Create a new, empty, read-only filesystem layer with the specified 123 `ID`, `Parent` and `MountLabel`. If `Parent` is an empty string, there is no 124 parent layer. `StorageOpt` is map of strings which indicate storage options. 125 126 **Response**: 127 ```json 128 { 129 "Err": "" 130 } 131 ``` 132 133 Respond with a non-empty string error if an error occurred. 134 135 ### /GraphDriver.CreateReadWrite 136 137 **Request**: 138 ```json 139 { 140 "ID": "46fe8644f2572fd1e505364f7581e0c9dbc7f14640bd1fb6ce97714fb6fc5187", 141 "Parent": "2cd9c322cb78a55e8212aa3ea8425a4180236d7106938ec921d0935a4b8ca142", 142 "MountLabel": "", 143 "StorageOpt": {} 144 } 145 ``` 146 147 Similar to `/GraphDriver.Create` but creates a read-write filesystem layer. 148 149 ### /GraphDriver.Remove 150 151 **Request**: 152 ```json 153 { 154 "ID": "46fe8644f2572fd1e505364f7581e0c9dbc7f14640bd1fb6ce97714fb6fc5187" 155 } 156 ``` 157 158 Remove the filesystem layer with this given `ID`. 159 160 **Response**: 161 ```json 162 { 163 "Err": "" 164 } 165 ``` 166 167 Respond with a non-empty string error if an error occurred. 168 169 ### /GraphDriver.Get 170 171 **Request**: 172 ```json 173 { 174 "ID": "46fe8644f2572fd1e505364f7581e0c9dbc7f14640bd1fb6ce97714fb6fc5187", 175 "MountLabel": "" 176 } 177 ``` 178 179 Get the mountpoint for the layered filesystem referred to by the given `ID`. 180 181 **Response**: 182 ```json 183 { 184 "Dir": "/var/mygraph/46fe8644f2572fd1e505364f7581e0c9dbc7f14640bd1fb6ce97714fb6fc5187", 185 "Err": "" 186 } 187 ``` 188 189 Respond with the absolute path to the mounted layered filesystem. 190 Respond with a non-empty string error if an error occurred. 191 192 ### /GraphDriver.Put 193 194 **Request**: 195 ```json 196 { 197 "ID": "46fe8644f2572fd1e505364f7581e0c9dbc7f14640bd1fb6ce97714fb6fc5187" 198 } 199 ``` 200 201 Release the system resources for the specified `ID`, such as unmounting the 202 filesystem layer. 203 204 **Response**: 205 ```json 206 { 207 "Err": "" 208 } 209 ``` 210 211 Respond with a non-empty string error if an error occurred. 212 213 ### /GraphDriver.Exists 214 215 **Request**: 216 ```json 217 { 218 "ID": "46fe8644f2572fd1e505364f7581e0c9dbc7f14640bd1fb6ce97714fb6fc5187" 219 } 220 ``` 221 222 Determine if a filesystem layer with the specified `ID` exists. 223 224 **Response**: 225 ```json 226 { 227 "Exists": true 228 } 229 ``` 230 231 Respond with a boolean for whether or not the filesystem layer with the specified 232 `ID` exists. 233 234 ### /GraphDriver.Status 235 236 **Request**: 237 ```json 238 {} 239 ``` 240 241 Get low-level diagnostic information about the graph driver. 242 243 **Response**: 244 ```json 245 { 246 "Status": [[]] 247 } 248 ``` 249 250 Respond with a 2-D array with key/value pairs for the underlying status 251 information. 252 253 254 ### /GraphDriver.GetMetadata 255 256 **Request**: 257 ```json 258 { 259 "ID": "46fe8644f2572fd1e505364f7581e0c9dbc7f14640bd1fb6ce97714fb6fc5187" 260 } 261 ``` 262 263 Get low-level diagnostic information about the layered filesystem with the 264 with the specified `ID` 265 266 **Response**: 267 ```json 268 { 269 "Metadata": {}, 270 "Err": "" 271 } 272 ``` 273 274 Respond with a set of key/value pairs containing the low-level diagnostic 275 information about the layered filesystem. 276 Respond with a non-empty string error if an error occurred. 277 278 ### /GraphDriver.Cleanup 279 280 **Request**: 281 ```json 282 {} 283 ``` 284 285 Perform necessary tasks to release resources help by the plugin, such as 286 unmounting all the layered file systems. 287 288 **Response**: 289 ```json 290 { 291 "Err": "" 292 } 293 ``` 294 295 Respond with a non-empty string error if an error occurred. 296 297 298 ### /GraphDriver.Diff 299 300 **Request**: 301 ```json 302 { 303 "ID": "46fe8644f2572fd1e505364f7581e0c9dbc7f14640bd1fb6ce97714fb6fc5187", 304 "Parent": "2cd9c322cb78a55e8212aa3ea8425a4180236d7106938ec921d0935a4b8ca142" 305 } 306 ``` 307 308 Get an archive of the changes between the filesystem layers specified by the `ID` 309 and `Parent`. `Parent` may be an empty string, in which case there is no parent. 310 311 **Response**: 312 ``` 313 {% raw %} 314 {{ TAR STREAM }} 315 {% endraw %} 316 ``` 317 318 ### /GraphDriver.Changes 319 320 **Request**: 321 ```json 322 { 323 "ID": "46fe8644f2572fd1e505364f7581e0c9dbc7f14640bd1fb6ce97714fb6fc5187", 324 "Parent": "2cd9c322cb78a55e8212aa3ea8425a4180236d7106938ec921d0935a4b8ca142" 325 } 326 ``` 327 328 Get a list of changes between the filesystem layers specified by the `ID` and 329 `Parent`. If `Parent` is an empty string, there is no parent. 330 331 **Response**: 332 ```json 333 { 334 "Changes": [{}], 335 "Err": "" 336 } 337 ``` 338 339 Respond with a list of changes. The structure of a change is: 340 ```json 341 "Path": "/some/path", 342 "Kind": 0, 343 ``` 344 345 Where the `Path` is the filesystem path within the layered filesystem that is 346 changed and `Kind` is an integer specifying the type of change that occurred: 347 348 - 0 - Modified 349 - 1 - Added 350 - 2 - Deleted 351 352 Respond with a non-empty string error if an error occurred. 353 354 ### /GraphDriver.ApplyDiff 355 356 **Request**: 357 ``` 358 {% raw %} 359 {{ TAR STREAM }} 360 {% endraw %} 361 ``` 362 363 Extract the changeset from the given diff into the layer with the specified `ID` 364 and `Parent` 365 366 **Query Parameters**: 367 368 - id (required)- the `ID` of the new filesystem layer to extract the diff to 369 - parent (required)- the `Parent` of the given `ID` 370 371 **Response**: 372 ```json 373 { 374 "Size": 512366, 375 "Err": "" 376 } 377 ``` 378 379 Respond with the size of the new layer in bytes. 380 Respond with a non-empty string error if an error occurred. 381 382 ### /GraphDriver.DiffSize 383 384 **Request**: 385 ```json 386 { 387 "ID": "46fe8644f2572fd1e505364f7581e0c9dbc7f14640bd1fb6ce97714fb6fc5187", 388 "Parent": "2cd9c322cb78a55e8212aa3ea8425a4180236d7106938ec921d0935a4b8ca142" 389 } 390 ``` 391 392 Calculate the changes between the specified `ID` 393 394 **Response**: 395 ```json 396 { 397 "Size": 512366, 398 "Err": "" 399 } 400 ``` 401 402 Respond with the size changes between the specified `ID` and `Parent` 403 Respond with a non-empty string error if an error occurred.