github.com/xeptore/docker-cli@v20.10.14+incompatible/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  ```console
    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  ```
   314  {% raw %}
   315  {{ TAR STREAM }}
   316  {% endraw %}
   317  ```
   318  
   319  ### /GraphDriver.Changes
   320  
   321  **Request**:
   322  ```json
   323  {
   324    "ID": "46fe8644f2572fd1e505364f7581e0c9dbc7f14640bd1fb6ce97714fb6fc5187",
   325    "Parent": "2cd9c322cb78a55e8212aa3ea8425a4180236d7106938ec921d0935a4b8ca142"
   326  }
   327  ```
   328  
   329  Get a list of changes between the filesystem layers specified by the `ID` and
   330  `Parent`. If `Parent` is an empty string, there is no parent.
   331  
   332  **Response**:
   333  ```json
   334  {
   335    "Changes": [{}],
   336    "Err": ""
   337  }
   338  ```
   339  
   340  Respond with a list of changes. The structure of a change is:
   341  ```json
   342    "Path": "/some/path",
   343    "Kind": 0,
   344  ```
   345  
   346  Where the `Path` is the filesystem path within the layered filesystem that is
   347  changed and `Kind` is an integer specifying the type of change that occurred:
   348  
   349  - 0 - Modified
   350  - 1 - Added
   351  - 2 - Deleted
   352  
   353  Respond with a non-empty string error if an error occurred.
   354  
   355  ### /GraphDriver.ApplyDiff
   356  
   357  **Request**:
   358  
   359  ```
   360  {% raw %}
   361  {{ TAR STREAM }}
   362  {% endraw %}
   363  ```
   364  
   365  Extract the changeset from the given diff into the layer with the specified `ID`
   366  and `Parent`
   367  
   368  **Query Parameters**:
   369  
   370  - id (required)- the `ID` of the new filesystem layer to extract the diff to
   371  - parent (required)- the `Parent` of the given `ID`
   372  
   373  **Response**:
   374  ```json
   375  {
   376    "Size": 512366,
   377    "Err": ""
   378  }
   379  ```
   380  
   381  Respond with the size of the new layer in bytes.
   382  Respond with a non-empty string error if an error occurred.
   383  
   384  ### /GraphDriver.DiffSize
   385  
   386  **Request**:
   387  ```json
   388  {
   389    "ID": "46fe8644f2572fd1e505364f7581e0c9dbc7f14640bd1fb6ce97714fb6fc5187",
   390    "Parent": "2cd9c322cb78a55e8212aa3ea8425a4180236d7106938ec921d0935a4b8ca142"
   391  }
   392  ```
   393  
   394  Calculate the changes between the specified `ID`
   395  
   396  **Response**:
   397  ```json
   398  {
   399    "Size": 512366,
   400    "Err": ""
   401  }
   402  ```
   403  
   404  Respond with the size changes between the specified `ID` and `Parent`
   405  Respond with a non-empty string error if an error occurred.