Signed-off-by: Victor Vieux <vieux@docker.com>
| ... | ... |
@@ -15,8 +15,6 @@ weight = 6 |
| 15 | 15 |
|
| 16 | 16 |
Currently, you can extend Docker Engine by adding a plugin. This section contains the following topics: |
| 17 | 17 |
|
| 18 |
-* [Understand Docker plugins](plugins.md) |
|
| 19 |
-* [Write a volume plugin](plugins_volume.md) |
|
| 20 |
-* [Write a network plugin](plugins_network.md) |
|
| 21 |
-* [Write an authorization plugin](plugins_authorization.md) |
|
| 22 |
-* [Docker plugin API](plugin_api.md) |
|
| 18 |
+* [New Docker Plugin System](new/index.md) |
|
| 19 |
+* [Legacy Docker Plugins](legacy/index.md) |
|
| 20 |
+ |
| 23 | 21 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,22 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "Legacy Docker Plugins" |
|
| 2 |
+description = "How to extend Docker Engine with plugins" |
|
| 3 |
+keywords = ["extend, plugins, docker, documentation, developer"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+identifier = "extend_legacy" |
|
| 6 |
+parent = "engine_extend" |
|
| 7 |
+weight = 7 |
|
| 8 |
+<![end-metadata]--> |
|
| 9 |
+ |
|
| 10 |
+ |
|
| 11 |
+## Legacy Docker Plugins |
|
| 12 |
+ |
|
| 13 |
+Currently, you can extend Docker Engine by adding a plugin. This section contains the following topics: |
|
| 14 |
+ |
|
| 15 |
+* [Understand Docker plugins](plugins.md) |
|
| 16 |
+* [Write a volume plugin](plugins_volume.md) |
|
| 17 |
+* [Write a network plugin](plugins_network.md) |
|
| 18 |
+* [Write an authorization plugin](plugins_authorization.md) |
|
| 19 |
+* [Docker plugin API](plugin_api.md) |
| 0 | 20 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,188 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "Plugins API" |
|
| 2 |
+description = "How to write Docker plugins extensions " |
|
| 3 |
+keywords = ["API, Usage, plugins, documentation, developer"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "engine_extend" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# Docker Plugin API |
|
| 10 |
+ |
|
| 11 |
+Docker plugins are out-of-process extensions which add capabilities to the |
|
| 12 |
+Docker Engine. |
|
| 13 |
+ |
|
| 14 |
+This page is intended for people who want to develop their own Docker plugin. |
|
| 15 |
+If you just want to learn about or use Docker plugins, look |
|
| 16 |
+[here](plugins.md). |
|
| 17 |
+ |
|
| 18 |
+## What plugins are |
|
| 19 |
+ |
|
| 20 |
+A plugin is a process running on the same or a different host as the docker daemon, |
|
| 21 |
+which registers itself by placing a file on the same docker host in one of the plugin |
|
| 22 |
+directories described in [Plugin discovery](#plugin-discovery). |
|
| 23 |
+ |
|
| 24 |
+Plugins have human-readable names, which are short, lowercase strings. For |
|
| 25 |
+example, `flocker` or `weave`. |
|
| 26 |
+ |
|
| 27 |
+Plugins can run inside or outside containers. Currently running them outside |
|
| 28 |
+containers is recommended. |
|
| 29 |
+ |
|
| 30 |
+## Plugin discovery |
|
| 31 |
+ |
|
| 32 |
+Docker discovers plugins by looking for them in the plugin directory whenever a |
|
| 33 |
+user or container tries to use one by name. |
|
| 34 |
+ |
|
| 35 |
+There are three types of files which can be put in the plugin directory. |
|
| 36 |
+ |
|
| 37 |
+* `.sock` files are UNIX domain sockets. |
|
| 38 |
+* `.spec` files are text files containing a URL, such as `unix:///other.sock` or `tcp://localhost:8080`. |
|
| 39 |
+* `.json` files are text files containing a full json specification for the plugin. |
|
| 40 |
+ |
|
| 41 |
+Plugins with UNIX domain socket files must run on the same docker host, whereas |
|
| 42 |
+plugins with spec or json files can run on a different host if a remote URL is specified. |
|
| 43 |
+ |
|
| 44 |
+UNIX domain socket files must be located under `/run/docker/plugins`, whereas |
|
| 45 |
+spec files can be located either under `/etc/docker/plugins` or `/usr/lib/docker/plugins`. |
|
| 46 |
+ |
|
| 47 |
+The name of the file (excluding the extension) determines the plugin name. |
|
| 48 |
+ |
|
| 49 |
+For example, the `flocker` plugin might create a UNIX socket at |
|
| 50 |
+`/run/docker/plugins/flocker.sock`. |
|
| 51 |
+ |
|
| 52 |
+You can define each plugin into a separated subdirectory if you want to isolate definitions from each other. |
|
| 53 |
+For example, you can create the `flocker` socket under `/run/docker/plugins/flocker/flocker.sock` and only |
|
| 54 |
+mount `/run/docker/plugins/flocker` inside the `flocker` container. |
|
| 55 |
+ |
|
| 56 |
+Docker always searches for unix sockets in `/run/docker/plugins` first. It checks for spec or json files under |
|
| 57 |
+`/etc/docker/plugins` and `/usr/lib/docker/plugins` if the socket doesn't exist. The directory scan stops as |
|
| 58 |
+soon as it finds the first plugin definition with the given name. |
|
| 59 |
+ |
|
| 60 |
+### JSON specification |
|
| 61 |
+ |
|
| 62 |
+This is the JSON format for a plugin: |
|
| 63 |
+ |
|
| 64 |
+```json |
|
| 65 |
+{
|
|
| 66 |
+ "Name": "plugin-example", |
|
| 67 |
+ "Addr": "https://example.com/docker/plugin", |
|
| 68 |
+ "TLSConfig": {
|
|
| 69 |
+ "InsecureSkipVerify": false, |
|
| 70 |
+ "CAFile": "/usr/shared/docker/certs/example-ca.pem", |
|
| 71 |
+ "CertFile": "/usr/shared/docker/certs/example-cert.pem", |
|
| 72 |
+ "KeyFile": "/usr/shared/docker/certs/example-key.pem", |
|
| 73 |
+ } |
|
| 74 |
+} |
|
| 75 |
+``` |
|
| 76 |
+ |
|
| 77 |
+The `TLSConfig` field is optional and TLS will only be verified if this configuration is present. |
|
| 78 |
+ |
|
| 79 |
+## Plugin lifecycle |
|
| 80 |
+ |
|
| 81 |
+Plugins should be started before Docker, and stopped after Docker. For |
|
| 82 |
+example, when packaging a plugin for a platform which supports `systemd`, you |
|
| 83 |
+might use [`systemd` dependencies]( |
|
| 84 |
+http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Before=) to |
|
| 85 |
+manage startup and shutdown order. |
|
| 86 |
+ |
|
| 87 |
+When upgrading a plugin, you should first stop the Docker daemon, upgrade the |
|
| 88 |
+plugin, then start Docker again. |
|
| 89 |
+ |
|
| 90 |
+## Plugin activation |
|
| 91 |
+ |
|
| 92 |
+When a plugin is first referred to -- either by a user referring to it by name |
|
| 93 |
+(e.g. `docker run --volume-driver=foo`) or a container already configured to |
|
| 94 |
+use a plugin being started -- Docker looks for the named plugin in the plugin |
|
| 95 |
+directory and activates it with a handshake. See Handshake API below. |
|
| 96 |
+ |
|
| 97 |
+Plugins are *not* activated automatically at Docker daemon startup. Rather, |
|
| 98 |
+they are activated only lazily, or on-demand, when they are needed. |
|
| 99 |
+ |
|
| 100 |
+## Systemd socket activation |
|
| 101 |
+ |
|
| 102 |
+Plugins may also be socket activated by `systemd`. The official [Plugins helpers](https://github.com/docker/go-plugins-helpers) |
|
| 103 |
+natively supports socket activation. In order for a plugin to be socket activated it needs |
|
| 104 |
+a `service` file and a `socket` file. |
|
| 105 |
+ |
|
| 106 |
+The `service` file (for example `/lib/systemd/system/your-plugin.service`): |
|
| 107 |
+ |
|
| 108 |
+``` |
|
| 109 |
+[Unit] |
|
| 110 |
+Description=Your plugin |
|
| 111 |
+Before=docker.service |
|
| 112 |
+After=network.target your-plugin.socket |
|
| 113 |
+Requires=your-plugin.socket docker.service |
|
| 114 |
+ |
|
| 115 |
+[Service] |
|
| 116 |
+ExecStart=/usr/lib/docker/your-plugin |
|
| 117 |
+ |
|
| 118 |
+[Install] |
|
| 119 |
+WantedBy=multi-user.target |
|
| 120 |
+``` |
|
| 121 |
+The `socket` file (for example `/lib/systemd/system/your-plugin.socket`): |
|
| 122 |
+``` |
|
| 123 |
+[Unit] |
|
| 124 |
+Description=Your plugin |
|
| 125 |
+ |
|
| 126 |
+[Socket] |
|
| 127 |
+ListenStream=/run/docker/plugins/your-plugin.sock |
|
| 128 |
+ |
|
| 129 |
+[Install] |
|
| 130 |
+WantedBy=sockets.target |
|
| 131 |
+``` |
|
| 132 |
+ |
|
| 133 |
+This will allow plugins to be actually started when the Docker daemon connects to |
|
| 134 |
+the sockets they're listening on (for instance the first time the daemon uses them |
|
| 135 |
+or if one of the plugin goes down accidentally). |
|
| 136 |
+ |
|
| 137 |
+## API design |
|
| 138 |
+ |
|
| 139 |
+The Plugin API is RPC-style JSON over HTTP, much like webhooks. |
|
| 140 |
+ |
|
| 141 |
+Requests flow *from* the Docker daemon *to* the plugin. So the plugin needs to |
|
| 142 |
+implement an HTTP server and bind this to the UNIX socket mentioned in the |
|
| 143 |
+"plugin discovery" section. |
|
| 144 |
+ |
|
| 145 |
+All requests are HTTP `POST` requests. |
|
| 146 |
+ |
|
| 147 |
+The API is versioned via an Accept header, which currently is always set to |
|
| 148 |
+`application/vnd.docker.plugins.v1+json`. |
|
| 149 |
+ |
|
| 150 |
+## Handshake API |
|
| 151 |
+ |
|
| 152 |
+Plugins are activated via the following "handshake" API call. |
|
| 153 |
+ |
|
| 154 |
+### /Plugin.Activate |
|
| 155 |
+ |
|
| 156 |
+**Request:** empty body |
|
| 157 |
+ |
|
| 158 |
+**Response:** |
|
| 159 |
+``` |
|
| 160 |
+{
|
|
| 161 |
+ "Implements": ["VolumeDriver"] |
|
| 162 |
+} |
|
| 163 |
+``` |
|
| 164 |
+ |
|
| 165 |
+Responds with a list of Docker subsystems which this plugin implements. |
|
| 166 |
+After activation, the plugin will then be sent events from this subsystem. |
|
| 167 |
+ |
|
| 168 |
+Possible values are: |
|
| 169 |
+ |
|
| 170 |
+* [`authz`](plugins_authorization.md) |
|
| 171 |
+* [`NetworkDriver`](plugins_network.md) |
|
| 172 |
+* [`VolumeDriver`](plugins_volume.md) |
|
| 173 |
+ |
|
| 174 |
+ |
|
| 175 |
+## Plugin retries |
|
| 176 |
+ |
|
| 177 |
+Attempts to call a method on a plugin are retried with an exponential backoff |
|
| 178 |
+for up to 30 seconds. This may help when packaging plugins as containers, since |
|
| 179 |
+it gives plugin containers a chance to start up before failing any user |
|
| 180 |
+containers which depend on them. |
|
| 181 |
+ |
|
| 182 |
+## Plugins helpers |
|
| 183 |
+ |
|
| 184 |
+To ease plugins development, we're providing an `sdk` for each kind of plugins |
|
| 185 |
+currently supported by Docker at [docker/go-plugins-helpers](https://github.com/docker/go-plugins-helpers). |
| 0 | 186 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,87 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "Extending Engine with plugins" |
|
| 2 |
+description = "How to add additional functionality to Docker with plugins extensions" |
|
| 3 |
+keywords = ["Examples, Usage, plugins, docker, documentation, user guide"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "engine_extend" |
|
| 6 |
+weight=-1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# Understand Engine plugins |
|
| 10 |
+ |
|
| 11 |
+You can extend the capabilities of the Docker Engine by loading third-party |
|
| 12 |
+plugins. This page explains the types of plugins and provides links to several |
|
| 13 |
+volume and network plugins for Docker. |
|
| 14 |
+ |
|
| 15 |
+## Types of plugins |
|
| 16 |
+ |
|
| 17 |
+Plugins extend Docker's functionality. They come in specific types. For |
|
| 18 |
+example, a [volume plugin](plugins_volume.md) might enable Docker |
|
| 19 |
+volumes to persist across multiple Docker hosts and a |
|
| 20 |
+[network plugin](plugins_network.md) might provide network plumbing. |
|
| 21 |
+ |
|
| 22 |
+Currently Docker supports authorization, volume and network driver plugins. In the future it |
|
| 23 |
+will support additional plugin types. |
|
| 24 |
+ |
|
| 25 |
+## Installing a plugin |
|
| 26 |
+ |
|
| 27 |
+Follow the instructions in the plugin's documentation. |
|
| 28 |
+ |
|
| 29 |
+## Finding a plugin |
|
| 30 |
+ |
|
| 31 |
+The sections below provide an inexhaustive overview of available plugins. |
|
| 32 |
+ |
|
| 33 |
+<style> |
|
| 34 |
+#DocumentationText tr td:first-child { white-space: nowrap;}
|
|
| 35 |
+</style> |
|
| 36 |
+ |
|
| 37 |
+### Network plugins |
|
| 38 |
+ |
|
| 39 |
+Plugin | Description |
|
| 40 |
+----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| 41 |
+[Contiv Networking](https://github.com/contiv/netplugin) | An open source network plugin to provide infrastructure and security policies for a multi-tenant micro services deployment, while providing an integration to physical network for non-container workload. Contiv Networking implements the remote driver and IPAM APIs available in Docker 1.9 onwards. |
|
| 42 |
+[Kuryr Network Plugin](https://github.com/openstack/kuryr) | A network plugin is developed as part of the OpenStack Kuryr project and implements the Docker networking (libnetwork) remote driver API by utilizing Neutron, the OpenStack networking service. It includes an IPAM driver as well. |
|
| 43 |
+[Weave Network Plugin](https://www.weave.works/docs/net/latest/introducing-weave/) | A network plugin that creates a virtual network that connects your Docker containers - across multiple hosts or clouds and enables automatic discovery of applications. Weave networks are resilient, partition tolerant, secure and work in partially connected networks, and other adverse environments - all configured with delightful simplicity. |
|
| 44 |
+ |
|
| 45 |
+### Volume plugins |
|
| 46 |
+ |
|
| 47 |
+Plugin | Description |
|
| 48 |
+----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| 49 |
+[Azure File Storage plugin](https://github.com/Azure/azurefile-dockervolumedriver) | Lets you mount Microsoft [Azure File Storage](https://azure.microsoft.com/blog/azure-file-storage-now-generally-available/) shares to Docker containers as volumes using the SMB 3.0 protocol. [Learn more](https://azure.microsoft.com/blog/persistent-docker-volumes-with-azure-file-storage/). |
|
| 50 |
+[Blockbridge plugin](https://github.com/blockbridge/blockbridge-docker-volume) | A volume plugin that provides access to an extensible set of container-based persistent storage options. It supports single and multi-host Docker environments with features that include tenant isolation, automated provisioning, encryption, secure deletion, snapshots and QoS. |
|
| 51 |
+[Contiv Volume Plugin](https://github.com/contiv/volplugin) | An open source volume plugin that provides multi-tenant, persistent, distributed storage with intent based consumption using ceph underneath. |
|
| 52 |
+[Convoy plugin](https://github.com/rancher/convoy) | A volume plugin for a variety of storage back-ends including device mapper and NFS. It's a simple standalone executable written in Go and provides the framework to support vendor-specific extensions such as snapshots, backups and restore. |
|
| 53 |
+[DRBD plugin](https://www.drbd.org/en/supported-projects/docker) | A volume plugin that provides highly available storage replicated by [DRBD](https://www.drbd.org). Data written to the docker volume is replicated in a cluster of DRBD nodes. |
|
| 54 |
+[Flocker plugin](https://clusterhq.com/docker-plugin/) | A volume plugin that provides multi-host portable volumes for Docker, enabling you to run databases and other stateful containers and move them around across a cluster of machines. |
|
| 55 |
+[gce-docker plugin](https://github.com/mcuadros/gce-docker) | A volume plugin able to attach, format and mount Google Compute [persistent-disks](https://cloud.google.com/compute/docs/disks/persistent-disks). |
|
| 56 |
+[GlusterFS plugin](https://github.com/calavera/docker-volume-glusterfs) | A volume plugin that provides multi-host volumes management for Docker using GlusterFS. |
|
| 57 |
+[Horcrux Volume Plugin](https://github.com/muthu-r/horcrux) | A volume plugin that allows on-demand, version controlled access to your data. Horcrux is an open-source plugin, written in Go, and supports SCP, [Minio](https://www.minio.io) and Amazon S3. |
|
| 58 |
+[HPE 3Par Volume Plugin](https://github.com/hpe-storage/python-hpedockerplugin/) | A volume plugin that supports HPE 3Par and StoreVirtual iSCSI storage arrays. |
|
| 59 |
+[IPFS Volume Plugin](http://github.com/vdemeester/docker-volume-ipfs) | An open source volume plugin that allows using an [ipfs](https://ipfs.io/) filesystem as a volume. |
|
| 60 |
+[Keywhiz plugin](https://github.com/calavera/docker-volume-keywhiz) | A plugin that provides credentials and secret management using Keywhiz as a central repository. |
|
| 61 |
+[Local Persist Plugin](https://github.com/CWSpear/local-persist) | A volume plugin that extends the default `local` driver's functionality by allowing you specify a mountpoint anywhere on the host, which enables the files to *always persist*, even if the volume is removed via `docker volume rm`. |
|
| 62 |
+[NetApp Plugin](https://github.com/NetApp/netappdvp) (nDVP) | A volume plugin that provides direct integration with the Docker ecosystem for the NetApp storage portfolio. The nDVP package supports the provisioning and management of storage resources from the storage platform to Docker hosts, with a robust framework for adding additional platforms in the future. |
|
| 63 |
+[Netshare plugin](https://github.com/ContainX/docker-volume-netshare) | A volume plugin that provides volume management for NFS 3/4, AWS EFS and CIFS file systems. |
|
| 64 |
+[OpenStorage Plugin](https://github.com/libopenstorage/openstorage) | A cluster-aware volume plugin that provides volume management for file and block storage solutions. It implements a vendor neutral specification for implementing extensions such as CoS, encryption, and snapshots. It has example drivers based on FUSE, NFS, NBD and EBS to name a few. |
|
| 65 |
+[Quobyte Volume Plugin](https://github.com/quobyte/docker-volume) | A volume plugin that connects Docker to [Quobyte](http://www.quobyte.com/containers)'s data center file system, a general-purpose scalable and fault-tolerant storage platform. |
|
| 66 |
+[REX-Ray plugin](https://github.com/emccode/rexray) | A volume plugin which is written in Go and provides advanced storage functionality for many platforms including VirtualBox, EC2, Google Compute Engine, OpenStack, and EMC. |
|
| 67 |
+[Virtuozzo Storage and Ploop plugin](https://github.com/virtuozzo/docker-volume-ploop) | A volume plugin with support for Virtuozzo Storage distributed cloud file system as well as ploop devices. |
|
| 68 |
+[VMware vSphere Storage Plugin](https://github.com/vmware/docker-volume-vsphere) | Docker Volume Driver for vSphere enables customers to address persistent storage requirements for Docker containers in vSphere environments. |
|
| 69 |
+ |
|
| 70 |
+### Authorization plugins |
|
| 71 |
+ |
|
| 72 |
+ Plugin | Description |
|
| 73 |
+------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
| 74 |
+ [Twistlock AuthZ Broker](https://github.com/twistlock/authz) | A basic extendable authorization plugin that runs directly on the host or inside a container. This plugin allows you to define user policies that it evaluates during authorization. Basic authorization is provided if Docker daemon is started with the --tlsverify flag (username is extracted from the certificate common name). |
|
| 75 |
+ |
|
| 76 |
+## Troubleshooting a plugin |
|
| 77 |
+ |
|
| 78 |
+If you are having problems with Docker after loading a plugin, ask the authors |
|
| 79 |
+of the plugin for help. The Docker team may not be able to assist you. |
|
| 80 |
+ |
|
| 81 |
+## Writing a plugin |
|
| 82 |
+ |
|
| 83 |
+If you are interested in writing a plugin for Docker, or seeing how they work |
|
| 84 |
+under the hood, see the [docker plugins reference](plugin_api.md). |
| 0 | 85 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,252 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "Access authorization plugin" |
|
| 2 |
+description = "How to create authorization plugins to manage access control to your Docker daemon." |
|
| 3 |
+keywords = ["security, authorization, authentication, docker, documentation, plugin, extend"] |
|
| 4 |
+aliases = ["/engine/extend/authorization/"] |
|
| 5 |
+[menu.main] |
|
| 6 |
+parent = "engine_extend" |
|
| 7 |
+weight = -1 |
|
| 8 |
+<![end-metadata]--> |
|
| 9 |
+ |
|
| 10 |
+ |
|
| 11 |
+# Create an authorization plugin |
|
| 12 |
+ |
|
| 13 |
+Docker's out-of-the-box authorization model is all or nothing. Any user with |
|
| 14 |
+permission to access the Docker daemon can run any Docker client command. The |
|
| 15 |
+same is true for callers using Docker's remote API to contact the daemon. If you |
|
| 16 |
+require greater access control, you can create authorization plugins and add |
|
| 17 |
+them to your Docker daemon configuration. Using an authorization plugin, a |
|
| 18 |
+Docker administrator can configure granular access policies for managing access |
|
| 19 |
+to Docker daemon. |
|
| 20 |
+ |
|
| 21 |
+Anyone with the appropriate skills can develop an authorization plugin. These |
|
| 22 |
+skills, at their most basic, are knowledge of Docker, understanding of REST, and |
|
| 23 |
+sound programming knowledge. This document describes the architecture, state, |
|
| 24 |
+and methods information available to an authorization plugin developer. |
|
| 25 |
+ |
|
| 26 |
+## Basic principles |
|
| 27 |
+ |
|
| 28 |
+Docker's [plugin infrastructure](plugin_api.md) enables |
|
| 29 |
+extending Docker by loading, removing and communicating with |
|
| 30 |
+third-party components using a generic API. The access authorization subsystem |
|
| 31 |
+was built using this mechanism. |
|
| 32 |
+ |
|
| 33 |
+Using this subsystem, you don't need to rebuild the Docker daemon to add an |
|
| 34 |
+authorization plugin. You can add a plugin to an installed Docker daemon. You do |
|
| 35 |
+need to restart the Docker daemon to add a new plugin. |
|
| 36 |
+ |
|
| 37 |
+An authorization plugin approves or denies requests to the Docker daemon based |
|
| 38 |
+on both the current authentication context and the command context. The |
|
| 39 |
+authentication context contains all user details and the authentication method. |
|
| 40 |
+The command context contains all the relevant request data. |
|
| 41 |
+ |
|
| 42 |
+Authorization plugins must follow the rules described in [Docker Plugin API](plugin_api.md). |
|
| 43 |
+Each plugin must reside within directories described under the |
|
| 44 |
+[Plugin discovery](plugin_api.md#plugin-discovery) section. |
|
| 45 |
+ |
|
| 46 |
+**Note**: the abbreviations `AuthZ` and `AuthN` mean authorization and authentication |
|
| 47 |
+respectively. |
|
| 48 |
+ |
|
| 49 |
+## Default user authorization mechanism |
|
| 50 |
+ |
|
| 51 |
+If TLS is enabled in the [Docker daemon](../security/https.md), the default user authorization flow extracts the user details from the certificate subject name. |
|
| 52 |
+That is, the `User` field is set to the client certificate subject common name, and the `AuthenticationMethod` field is set to `TLS`. |
|
| 53 |
+ |
|
| 54 |
+## Basic architecture |
|
| 55 |
+ |
|
| 56 |
+You are responsible for registering your plugin as part of the Docker daemon |
|
| 57 |
+startup. You can install multiple plugins and chain them together. This chain |
|
| 58 |
+can be ordered. Each request to the daemon passes in order through the chain. |
|
| 59 |
+Only when all the plugins grant access to the resource, is the access granted. |
|
| 60 |
+ |
|
| 61 |
+When an HTTP request is made to the Docker daemon through the CLI or via the |
|
| 62 |
+remote API, the authentication subsystem passes the request to the installed |
|
| 63 |
+authentication plugin(s). The request contains the user (caller) and command |
|
| 64 |
+context. The plugin is responsible for deciding whether to allow or deny the |
|
| 65 |
+request. |
|
| 66 |
+ |
|
| 67 |
+The sequence diagrams below depict an allow and deny authorization flow: |
|
| 68 |
+ |
|
| 69 |
+ |
|
| 70 |
+ |
|
| 71 |
+ |
|
| 72 |
+ |
|
| 73 |
+Each request sent to the plugin includes the authenticated user, the HTTP |
|
| 74 |
+headers, and the request/response body. Only the user name and the |
|
| 75 |
+authentication method used are passed to the plugin. Most importantly, no user |
|
| 76 |
+credentials or tokens are passed. Finally, not all request/response bodies |
|
| 77 |
+are sent to the authorization plugin. Only those request/response bodies where |
|
| 78 |
+the `Content-Type` is either `text/*` or `application/json` are sent. |
|
| 79 |
+ |
|
| 80 |
+For commands that can potentially hijack the HTTP connection (`HTTP |
|
| 81 |
+Upgrade`), such as `exec`, the authorization plugin is only called for the |
|
| 82 |
+initial HTTP requests. Once the plugin approves the command, authorization is |
|
| 83 |
+not applied to the rest of the flow. Specifically, the streaming data is not |
|
| 84 |
+passed to the authorization plugins. For commands that return chunked HTTP |
|
| 85 |
+response, such as `logs` and `events`, only the HTTP request is sent to the |
|
| 86 |
+authorization plugins. |
|
| 87 |
+ |
|
| 88 |
+During request/response processing, some authorization flows might |
|
| 89 |
+need to do additional queries to the Docker daemon. To complete such flows, |
|
| 90 |
+plugins can call the daemon API similar to a regular user. To enable these |
|
| 91 |
+additional queries, the plugin must provide the means for an administrator to |
|
| 92 |
+configure proper authentication and security policies. |
|
| 93 |
+ |
|
| 94 |
+## Docker client flows |
|
| 95 |
+ |
|
| 96 |
+To enable and configure the authorization plugin, the plugin developer must |
|
| 97 |
+support the Docker client interactions detailed in this section. |
|
| 98 |
+ |
|
| 99 |
+### Setting up Docker daemon |
|
| 100 |
+ |
|
| 101 |
+Enable the authorization plugin with a dedicated command line flag in the |
|
| 102 |
+`--authorization-plugin=PLUGIN_ID` format. The flag supplies a `PLUGIN_ID` |
|
| 103 |
+value. This value can be the plugin’s socket or a path to a specification file. |
|
| 104 |
+Authorization plugins can be loaded without restarting the daemon. Refer |
|
| 105 |
+to the [`dockerd` documentation](../reference/commandline/dockerd.md#configuration-reloading) for more information. |
|
| 106 |
+ |
|
| 107 |
+```bash |
|
| 108 |
+$ docker daemon --authorization-plugin=plugin1 --authorization-plugin=plugin2,... |
|
| 109 |
+``` |
|
| 110 |
+ |
|
| 111 |
+Docker's authorization subsystem supports multiple `--authorization-plugin` parameters. |
|
| 112 |
+ |
|
| 113 |
+### Calling authorized command (allow) |
|
| 114 |
+ |
|
| 115 |
+```bash |
|
| 116 |
+$ docker pull centos |
|
| 117 |
+... |
|
| 118 |
+f1b10cd84249: Pull complete |
|
| 119 |
+... |
|
| 120 |
+``` |
|
| 121 |
+ |
|
| 122 |
+### Calling unauthorized command (deny) |
|
| 123 |
+ |
|
| 124 |
+```bash |
|
| 125 |
+$ docker pull centos |
|
| 126 |
+... |
|
| 127 |
+docker: Error response from daemon: authorization denied by plugin PLUGIN_NAME: volumes are not allowed. |
|
| 128 |
+``` |
|
| 129 |
+ |
|
| 130 |
+### Error from plugins |
|
| 131 |
+ |
|
| 132 |
+```bash |
|
| 133 |
+$ docker pull centos |
|
| 134 |
+... |
|
| 135 |
+docker: Error response from daemon: plugin PLUGIN_NAME failed with error: AuthZPlugin.AuthZReq: Cannot connect to the Docker daemon. Is the docker daemon running on this host?. |
|
| 136 |
+``` |
|
| 137 |
+ |
|
| 138 |
+## API schema and implementation |
|
| 139 |
+ |
|
| 140 |
+In addition to Docker's standard plugin registration method, each plugin |
|
| 141 |
+should implement the following two methods: |
|
| 142 |
+ |
|
| 143 |
+* `/AuthZPlugin.AuthZReq` This authorize request method is called before the Docker daemon processes the client request. |
|
| 144 |
+ |
|
| 145 |
+* `/AuthZPlugin.AuthZRes` This authorize response method is called before the response is returned from Docker daemon to the client. |
|
| 146 |
+ |
|
| 147 |
+#### /AuthZPlugin.AuthZReq |
|
| 148 |
+ |
|
| 149 |
+**Request**: |
|
| 150 |
+ |
|
| 151 |
+```json |
|
| 152 |
+{
|
|
| 153 |
+ "User": "The user identification", |
|
| 154 |
+ "UserAuthNMethod": "The authentication method used", |
|
| 155 |
+ "RequestMethod": "The HTTP method", |
|
| 156 |
+ "RequestURI": "The HTTP request URI", |
|
| 157 |
+ "RequestBody": "Byte array containing the raw HTTP request body", |
|
| 158 |
+ "RequestHeader": "Byte array containing the raw HTTP request header as a map[string][]string " |
|
| 159 |
+} |
|
| 160 |
+``` |
|
| 161 |
+ |
|
| 162 |
+**Response**: |
|
| 163 |
+ |
|
| 164 |
+```json |
|
| 165 |
+{
|
|
| 166 |
+ "Allow": "Determined whether the user is allowed or not", |
|
| 167 |
+ "Msg": "The authorization message", |
|
| 168 |
+ "Err": "The error message if things go wrong" |
|
| 169 |
+} |
|
| 170 |
+``` |
|
| 171 |
+#### /AuthZPlugin.AuthZRes |
|
| 172 |
+ |
|
| 173 |
+**Request**: |
|
| 174 |
+ |
|
| 175 |
+```json |
|
| 176 |
+{
|
|
| 177 |
+ "User": "The user identification", |
|
| 178 |
+ "UserAuthNMethod": "The authentication method used", |
|
| 179 |
+ "RequestMethod": "The HTTP method", |
|
| 180 |
+ "RequestURI": "The HTTP request URI", |
|
| 181 |
+ "RequestBody": "Byte array containing the raw HTTP request body", |
|
| 182 |
+ "RequestHeader": "Byte array containing the raw HTTP request header as a map[string][]string", |
|
| 183 |
+ "ResponseBody": "Byte array containing the raw HTTP response body", |
|
| 184 |
+ "ResponseHeader": "Byte array containing the raw HTTP response header as a map[string][]string", |
|
| 185 |
+ "ResponseStatusCode":"Response status code" |
|
| 186 |
+} |
|
| 187 |
+``` |
|
| 188 |
+ |
|
| 189 |
+**Response**: |
|
| 190 |
+ |
|
| 191 |
+```json |
|
| 192 |
+{
|
|
| 193 |
+ "Allow": "Determined whether the user is allowed or not", |
|
| 194 |
+ "Msg": "The authorization message", |
|
| 195 |
+ "Err": "The error message if things go wrong" |
|
| 196 |
+} |
|
| 197 |
+``` |
|
| 198 |
+ |
|
| 199 |
+### Request authorization |
|
| 200 |
+ |
|
| 201 |
+Each plugin must support two request authorization messages formats, one from the daemon to the plugin and then from the plugin to the daemon. The tables below detail the content expected in each message. |
|
| 202 |
+ |
|
| 203 |
+#### Daemon -> Plugin |
|
| 204 |
+ |
|
| 205 |
+Name | Type | Description |
|
| 206 |
+-----------------------|-------------------|------------------------------------------------------- |
|
| 207 |
+User | string | The user identification |
|
| 208 |
+Authentication method | string | The authentication method used |
|
| 209 |
+Request method | enum | The HTTP method (GET/DELETE/POST) |
|
| 210 |
+Request URI | string | The HTTP request URI including API version (e.g., v.1.17/containers/json) |
|
| 211 |
+Request headers | map[string]string | Request headers as key value pairs (without the authorization header) |
|
| 212 |
+Request body | []byte | Raw request body |
|
| 213 |
+ |
|
| 214 |
+ |
|
| 215 |
+#### Plugin -> Daemon |
|
| 216 |
+ |
|
| 217 |
+Name | Type | Description |
|
| 218 |
+--------|--------|---------------------------------------------------------------------------------- |
|
| 219 |
+Allow | bool | Boolean value indicating whether the request is allowed or denied |
|
| 220 |
+Msg | string | Authorization message (will be returned to the client in case the access is denied) |
|
| 221 |
+Err | string | Error message (will be returned to the client in case the plugin encounter an error. The string value supplied may appear in logs, so should not include confidential information) |
|
| 222 |
+ |
|
| 223 |
+### Response authorization |
|
| 224 |
+ |
|
| 225 |
+The plugin must support two authorization messages formats, one from the daemon to the plugin and then from the plugin to the daemon. The tables below detail the content expected in each message. |
|
| 226 |
+ |
|
| 227 |
+#### Daemon -> Plugin |
|
| 228 |
+ |
|
| 229 |
+ |
|
| 230 |
+Name | Type | Description |
|
| 231 |
+----------------------- |------------------ |---------------------------------------------------- |
|
| 232 |
+User | string | The user identification |
|
| 233 |
+Authentication method | string | The authentication method used |
|
| 234 |
+Request method | string | The HTTP method (GET/DELETE/POST) |
|
| 235 |
+Request URI | string | The HTTP request URI including API version (e.g., v.1.17/containers/json) |
|
| 236 |
+Request headers | map[string]string | Request headers as key value pairs (without the authorization header) |
|
| 237 |
+Request body | []byte | Raw request body |
|
| 238 |
+Response status code | int | Status code from the docker daemon |
|
| 239 |
+Response headers | map[string]string | Response headers as key value pairs |
|
| 240 |
+Response body | []byte | Raw docker daemon response body |
|
| 241 |
+ |
|
| 242 |
+ |
|
| 243 |
+#### Plugin -> Daemon |
|
| 244 |
+ |
|
| 245 |
+Name | Type | Description |
|
| 246 |
+--------|--------|---------------------------------------------------------------------------------- |
|
| 247 |
+Allow | bool | Boolean value indicating whether the response is allowed or denied |
|
| 248 |
+Msg | string | Authorization message (will be returned to the client in case the access is denied) |
|
| 249 |
+Err | string | Error message (will be returned to the client in case the plugin encounter an error. The string value supplied may appear in logs, so should not include confidential information) |
| 0 | 250 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,68 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "Docker network driver plugins" |
|
| 2 |
+description = "Network driver plugins." |
|
| 3 |
+keywords = ["Examples, Usage, plugins, docker, documentation, user guide"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "engine_extend" |
|
| 6 |
+<![end-metadata]--> |
|
| 7 |
+ |
|
| 8 |
+# Engine network driver plugins |
|
| 9 |
+ |
|
| 10 |
+Docker Engine network plugins enable Engine deployments to be extended to |
|
| 11 |
+support a wide range of networking technologies, such as VXLAN, IPVLAN, MACVLAN |
|
| 12 |
+or something completely different. Network driver plugins are supported via the |
|
| 13 |
+LibNetwork project. Each plugin is implemented as a "remote driver" for |
|
| 14 |
+LibNetwork, which shares plugin infrastructure with Engine. Effectively, network |
|
| 15 |
+driver plugins are activated in the same way as other plugins, and use the same |
|
| 16 |
+kind of protocol. |
|
| 17 |
+ |
|
| 18 |
+## Network driver plugins and swarm mode |
|
| 19 |
+ |
|
| 20 |
+Docker 1.12 adds support for cluster management and orchestration called |
|
| 21 |
+[swarm mode](../swarm/index.md). Docker Engine running in swarm mode currently |
|
| 22 |
+only supports the built-in overlay driver for networking. Therefore existing |
|
| 23 |
+networking plugins will not work in swarm mode. |
|
| 24 |
+ |
|
| 25 |
+When you run Docker Engine outside of swarm mode, all networking plugins that |
|
| 26 |
+worked in Docker 1.11 will continue to function normally. They do not require |
|
| 27 |
+any modification. |
|
| 28 |
+ |
|
| 29 |
+## Using network driver plugins |
|
| 30 |
+ |
|
| 31 |
+The means of installing and running a network driver plugin depend on the |
|
| 32 |
+particular plugin. So, be sure to install your plugin according to the |
|
| 33 |
+instructions obtained from the plugin developer. |
|
| 34 |
+ |
|
| 35 |
+Once running however, network driver plugins are used just like the built-in |
|
| 36 |
+network drivers: by being mentioned as a driver in network-oriented Docker |
|
| 37 |
+commands. For example, |
|
| 38 |
+ |
|
| 39 |
+ $ docker network create --driver weave mynet |
|
| 40 |
+ |
|
| 41 |
+Some network driver plugins are listed in [plugins](plugins.md) |
|
| 42 |
+ |
|
| 43 |
+The `mynet` network is now owned by `weave`, so subsequent commands |
|
| 44 |
+referring to that network will be sent to the plugin, |
|
| 45 |
+ |
|
| 46 |
+ $ docker run --network=mynet busybox top |
|
| 47 |
+ |
|
| 48 |
+ |
|
| 49 |
+## Write a network plugin |
|
| 50 |
+ |
|
| 51 |
+Network plugins implement the [Docker plugin |
|
| 52 |
+API](https://docs.docker.com/extend/plugin_api/) and the network plugin protocol |
|
| 53 |
+ |
|
| 54 |
+## Network plugin protocol |
|
| 55 |
+ |
|
| 56 |
+The network driver protocol, in addition to the plugin activation call, is |
|
| 57 |
+documented as part of libnetwork: |
|
| 58 |
+[https://github.com/docker/libnetwork/blob/master/docs/remote.md](https://github.com/docker/libnetwork/blob/master/docs/remote.md). |
|
| 59 |
+ |
|
| 60 |
+# Related Information |
|
| 61 |
+ |
|
| 62 |
+To interact with the Docker maintainers and other interested users, see the IRC channel `#docker-network`. |
|
| 63 |
+ |
|
| 64 |
+- [Docker networks feature overview](../userguide/networking/index.md) |
|
| 65 |
+- The [LibNetwork](https://github.com/docker/libnetwork) project |
| 0 | 66 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,267 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "Volume plugins" |
|
| 2 |
+description = "How to manage data with external volume plugins" |
|
| 3 |
+keywords = ["Examples, Usage, volume, docker, data, volumes, plugin, api"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "engine_extend" |
|
| 6 |
+<![end-metadata]--> |
|
| 7 |
+ |
|
| 8 |
+# Write a volume plugin |
|
| 9 |
+ |
|
| 10 |
+Docker Engine volume plugins enable Engine deployments to be integrated with |
|
| 11 |
+external storage systems, such as Amazon EBS, and enable data volumes to persist |
|
| 12 |
+beyond the lifetime of a single Engine host. See the [plugin |
|
| 13 |
+documentation](plugins.md) for more information. |
|
| 14 |
+ |
|
| 15 |
+## Changelog |
|
| 16 |
+ |
|
| 17 |
+### 1.12.0 |
|
| 18 |
+ |
|
| 19 |
+- Add `Status` field to `VolumeDriver.Get` response ([#21006](https://github.com/docker/docker/pull/21006#)) |
|
| 20 |
+- Add `VolumeDriver.Capabilities` to get capabilities of the volume driver([#22077](https://github.com/docker/docker/pull/22077)) |
|
| 21 |
+ |
|
| 22 |
+### 1.10.0 |
|
| 23 |
+ |
|
| 24 |
+- Add `VolumeDriver.Get` which gets the details about the volume ([#16534](https://github.com/docker/docker/pull/16534)) |
|
| 25 |
+- Add `VolumeDriver.List` which lists all volumes owned by the driver ([#16534](https://github.com/docker/docker/pull/16534)) |
|
| 26 |
+ |
|
| 27 |
+### 1.8.0 |
|
| 28 |
+ |
|
| 29 |
+- Initial support for volume driver plugins ([#14659](https://github.com/docker/docker/pull/14659)) |
|
| 30 |
+ |
|
| 31 |
+## Command-line changes |
|
| 32 |
+ |
|
| 33 |
+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: |
|
| 34 |
+ |
|
| 35 |
+ $ docker run -ti -v volumename:/data --volume-driver=flocker busybox sh |
|
| 36 |
+ |
|
| 37 |
+This command passes the `volumename` through to the volume plugin as a |
|
| 38 |
+user-given name for the volume. The `volumename` must not begin with a `/`. |
|
| 39 |
+ |
|
| 40 |
+By having the user specify a `volumename`, a plugin can associate the volume |
|
| 41 |
+with an external volume beyond the lifetime of a single container or container |
|
| 42 |
+host. This can be used, for example, to move a stateful container from one |
|
| 43 |
+server to another. |
|
| 44 |
+ |
|
| 45 |
+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. |
|
| 46 |
+ |
|
| 47 |
+ |
|
| 48 |
+## Create a VolumeDriver |
|
| 49 |
+ |
|
| 50 |
+The container creation endpoint (`/containers/create`) accepts a `VolumeDriver` |
|
| 51 |
+field of type `string` allowing to specify the name of the driver. It's default |
|
| 52 |
+value of `"local"` (the default driver for local volumes). |
|
| 53 |
+ |
|
| 54 |
+## Volume plugin protocol |
|
| 55 |
+ |
|
| 56 |
+If a plugin registers itself as a `VolumeDriver` when activated, then it is |
|
| 57 |
+expected to provide writeable paths on the host filesystem for the Docker |
|
| 58 |
+daemon to provide to containers to consume. |
|
| 59 |
+ |
|
| 60 |
+The Docker daemon handles bind-mounting the provided paths into user |
|
| 61 |
+containers. |
|
| 62 |
+ |
|
| 63 |
+> **Note**: Volume plugins should *not* write data to the `/var/lib/docker/` |
|
| 64 |
+> directory, including `/var/lib/docker/volumes`. The `/var/lib/docker/` |
|
| 65 |
+> directory is reserved for Docker. |
|
| 66 |
+ |
|
| 67 |
+### /VolumeDriver.Create |
|
| 68 |
+ |
|
| 69 |
+**Request**: |
|
| 70 |
+```json |
|
| 71 |
+{
|
|
| 72 |
+ "Name": "volume_name", |
|
| 73 |
+ "Opts": {}
|
|
| 74 |
+} |
|
| 75 |
+``` |
|
| 76 |
+ |
|
| 77 |
+Instruct the plugin that the user wants to create a volume, given a user |
|
| 78 |
+specified volume name. The plugin does not need to actually manifest the |
|
| 79 |
+volume on the filesystem yet (until Mount is called). |
|
| 80 |
+Opts is a map of driver specific options passed through from the user request. |
|
| 81 |
+ |
|
| 82 |
+**Response**: |
|
| 83 |
+```json |
|
| 84 |
+{
|
|
| 85 |
+ "Err": "" |
|
| 86 |
+} |
|
| 87 |
+``` |
|
| 88 |
+ |
|
| 89 |
+Respond with a string error if an error occurred. |
|
| 90 |
+ |
|
| 91 |
+### /VolumeDriver.Remove |
|
| 92 |
+ |
|
| 93 |
+**Request**: |
|
| 94 |
+```json |
|
| 95 |
+{
|
|
| 96 |
+ "Name": "volume_name" |
|
| 97 |
+} |
|
| 98 |
+``` |
|
| 99 |
+ |
|
| 100 |
+Delete the specified volume from disk. This request is issued when a user invokes `docker rm -v` to remove volumes associated with a container. |
|
| 101 |
+ |
|
| 102 |
+**Response**: |
|
| 103 |
+```json |
|
| 104 |
+{
|
|
| 105 |
+ "Err": "" |
|
| 106 |
+} |
|
| 107 |
+``` |
|
| 108 |
+ |
|
| 109 |
+Respond with a string error if an error occurred. |
|
| 110 |
+ |
|
| 111 |
+### /VolumeDriver.Mount |
|
| 112 |
+ |
|
| 113 |
+**Request**: |
|
| 114 |
+```json |
|
| 115 |
+{
|
|
| 116 |
+ "Name": "volume_name", |
|
| 117 |
+ "ID": "b87d7442095999a92b65b3d9691e697b61713829cc0ffd1bb72e4ccd51aa4d6c" |
|
| 118 |
+} |
|
| 119 |
+``` |
|
| 120 |
+ |
|
| 121 |
+Docker requires the plugin to provide a volume, given a user specified volume |
|
| 122 |
+name. This is called once per container start. If the same volume_name is requested |
|
| 123 |
+more than once, the plugin may need to keep track of each new mount request and provision |
|
| 124 |
+at the first mount request and deprovision at the last corresponding unmount request. |
|
| 125 |
+ |
|
| 126 |
+`ID` is a unique ID for the caller that is requesting the mount. |
|
| 127 |
+ |
|
| 128 |
+**Response**: |
|
| 129 |
+```json |
|
| 130 |
+{
|
|
| 131 |
+ "Mountpoint": "/path/to/directory/on/host", |
|
| 132 |
+ "Err": "" |
|
| 133 |
+} |
|
| 134 |
+``` |
|
| 135 |
+ |
|
| 136 |
+Respond with the path on the host filesystem where the volume has been made |
|
| 137 |
+available, and/or a string error if an error occurred. |
|
| 138 |
+ |
|
| 139 |
+### /VolumeDriver.Path |
|
| 140 |
+ |
|
| 141 |
+**Request**: |
|
| 142 |
+```json |
|
| 143 |
+{
|
|
| 144 |
+ "Name": "volume_name" |
|
| 145 |
+} |
|
| 146 |
+``` |
|
| 147 |
+ |
|
| 148 |
+Docker needs reminding of the path to the volume on the host. |
|
| 149 |
+ |
|
| 150 |
+**Response**: |
|
| 151 |
+```json |
|
| 152 |
+{
|
|
| 153 |
+ "Mountpoint": "/path/to/directory/on/host", |
|
| 154 |
+ "Err": "" |
|
| 155 |
+} |
|
| 156 |
+``` |
|
| 157 |
+ |
|
| 158 |
+Respond with the path on the host filesystem where the volume has been made |
|
| 159 |
+available, and/or a string error if an error occurred. `Mountpoint` is optional, |
|
| 160 |
+however the plugin may be queried again later if one is not provided. |
|
| 161 |
+ |
|
| 162 |
+### /VolumeDriver.Unmount |
|
| 163 |
+ |
|
| 164 |
+**Request**: |
|
| 165 |
+```json |
|
| 166 |
+{
|
|
| 167 |
+ "Name": "volume_name", |
|
| 168 |
+ "ID": "b87d7442095999a92b65b3d9691e697b61713829cc0ffd1bb72e4ccd51aa4d6c" |
|
| 169 |
+} |
|
| 170 |
+``` |
|
| 171 |
+ |
|
| 172 |
+Indication that Docker no longer is using the named volume. This is called once |
|
| 173 |
+per container stop. Plugin may deduce that it is safe to deprovision it at |
|
| 174 |
+this point. |
|
| 175 |
+ |
|
| 176 |
+`ID` is a unique ID for the caller that is requesting the mount. |
|
| 177 |
+ |
|
| 178 |
+**Response**: |
|
| 179 |
+```json |
|
| 180 |
+{
|
|
| 181 |
+ "Err": "" |
|
| 182 |
+} |
|
| 183 |
+``` |
|
| 184 |
+ |
|
| 185 |
+Respond with a string error if an error occurred. |
|
| 186 |
+ |
|
| 187 |
+ |
|
| 188 |
+### /VolumeDriver.Get |
|
| 189 |
+ |
|
| 190 |
+**Request**: |
|
| 191 |
+```json |
|
| 192 |
+{
|
|
| 193 |
+ "Name": "volume_name" |
|
| 194 |
+} |
|
| 195 |
+``` |
|
| 196 |
+ |
|
| 197 |
+Get the volume info. |
|
| 198 |
+ |
|
| 199 |
+ |
|
| 200 |
+**Response**: |
|
| 201 |
+```json |
|
| 202 |
+{
|
|
| 203 |
+ "Volume": {
|
|
| 204 |
+ "Name": "volume_name", |
|
| 205 |
+ "Mountpoint": "/path/to/directory/on/host", |
|
| 206 |
+ "Status": {}
|
|
| 207 |
+ }, |
|
| 208 |
+ "Err": "" |
|
| 209 |
+} |
|
| 210 |
+``` |
|
| 211 |
+ |
|
| 212 |
+Respond with a string error if an error occurred. `Mountpoint` and `Status` are |
|
| 213 |
+optional. |
|
| 214 |
+ |
|
| 215 |
+ |
|
| 216 |
+### /VolumeDriver.List |
|
| 217 |
+ |
|
| 218 |
+**Request**: |
|
| 219 |
+```json |
|
| 220 |
+{}
|
|
| 221 |
+``` |
|
| 222 |
+ |
|
| 223 |
+Get the list of volumes registered with the plugin. |
|
| 224 |
+ |
|
| 225 |
+**Response**: |
|
| 226 |
+```json |
|
| 227 |
+{
|
|
| 228 |
+ "Volumes": [ |
|
| 229 |
+ {
|
|
| 230 |
+ "Name": "volume_name", |
|
| 231 |
+ "Mountpoint": "/path/to/directory/on/host" |
|
| 232 |
+ } |
|
| 233 |
+ ], |
|
| 234 |
+ "Err": "" |
|
| 235 |
+} |
|
| 236 |
+``` |
|
| 237 |
+ |
|
| 238 |
+Respond with a string error if an error occurred. `Mountpoint` is optional. |
|
| 239 |
+ |
|
| 240 |
+### /VolumeDriver.Capabilities |
|
| 241 |
+ |
|
| 242 |
+**Request**: |
|
| 243 |
+```json |
|
| 244 |
+{}
|
|
| 245 |
+``` |
|
| 246 |
+ |
|
| 247 |
+Get the list of capabilities the driver supports. |
|
| 248 |
+The driver is not required to implement this endpoint, however in such cases |
|
| 249 |
+the default values will be taken. |
|
| 250 |
+ |
|
| 251 |
+**Response**: |
|
| 252 |
+```json |
|
| 253 |
+{
|
|
| 254 |
+ "Capabilities": {
|
|
| 255 |
+ "Scope": "global" |
|
| 256 |
+ } |
|
| 257 |
+} |
|
| 258 |
+``` |
|
| 259 |
+ |
|
| 260 |
+Supported scopes are `global` and `local`. Any other value in `Scope` will be |
|
| 261 |
+ignored and assumed to be `local`. Scope allows cluster managers to handle the |
|
| 262 |
+volume differently, for instance with a scope of `global`, the cluster manager |
|
| 263 |
+knows it only needs to create the volume once instead of on every engine. More |
|
| 264 |
+capabilities may be added in the future. |
| 0 | 265 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,18 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "New Docker Plugin System" |
|
| 2 |
+description = "How to extend Docker Engine with plugins" |
|
| 3 |
+keywords = ["extend, plugins, docker, documentation, developer"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+identifier = "extend_new" |
|
| 6 |
+parent = "engine_extend" |
|
| 7 |
+weight = 7 |
|
| 8 |
+<![end-metadata]--> |
|
| 9 |
+ |
|
| 10 |
+ |
|
| 11 |
+## New Docker Plugin System |
|
| 12 |
+ |
|
| 13 |
+Currently, you can extend Docker Engine by adding a plugin. This section contains the following topics: |
|
| 14 |
+ |
|
| 15 |
+* [Understand Docker plugins](plugins.md) |
| 0 | 16 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,227 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "New Plugin System" |
|
| 2 |
+description = "How to operate and create a plugin with the new system" |
|
| 3 |
+keywords = ["API, Usage, plugins, documentation, developer"] |
|
| 4 |
+advisory = "experimental" |
|
| 5 |
+[menu.main] |
|
| 6 |
+parent = "engine_extend" |
|
| 7 |
+weight=1 |
|
| 8 |
+<![end-metadata]--> |
|
| 9 |
+ |
|
| 10 |
+# New Plugin System |
|
| 11 |
+ |
|
| 12 |
+The goal of this document is to describe the current state of the new plugin system available today in the **experimental build** of Docker 1.12. |
|
| 13 |
+ |
|
| 14 |
+The main difference, compared to legacy plugins, is that plugins are now managed by Docker: plugins are installed, started, stopped and removed by docker. |
|
| 15 |
+ |
|
| 16 |
+Only volume drivers are currently supported but more types will be added in the next release. |
|
| 17 |
+ |
|
| 18 |
+This document is split in two parts, the user perspective, “how to operate a plugin” and the developer perspective “how to create a plugin” |
|
| 19 |
+ |
|
| 20 |
+ |
|
| 21 |
+## How to operate a plugin |
|
| 22 |
+ |
|
| 23 |
+Plugins are distributed as docker images, so they can be hosted on the Docker Hub or on a private registry. |
|
| 24 |
+Installing a plugin is very easy, it’s a simple command: `docker plugin install` |
|
| 25 |
+This command is going to pull the plugin from the Docker Hub / Private registry, ask the operator to accept privileges (for example, plugin requires access to a device on the host system), if necessary and enable it. |
|
| 26 |
+You can then check the status of the plugin with the docker plugin ls command, the plugin will be marked as ENABLED if it was started without issue. |
|
| 27 |
+ |
|
| 28 |
+Then, the plugin behavior is the same as legacy plugins, here is a full example using a sshfs plugin: |
|
| 29 |
+ |
|
| 30 |
+### install the plugin |
|
| 31 |
+```bash |
|
| 32 |
+$ docker plugin install vieux/sshfs |
|
| 33 |
+Plugin "vieux/sshfs" is requesting the following privileges: |
|
| 34 |
+ - network: [host] |
|
| 35 |
+ - capabilities: [CAP_SYS_ADMIN] |
|
| 36 |
+Do you grant the above permissions? [y/N] y |
|
| 37 |
+vieux/sshfs |
|
| 38 |
+``` |
|
| 39 |
+ |
|
| 40 |
+Here the plugin requests 2 privileges, the `CAP_SYS_ADMIN` capability to be able to do mount inside the plugin and `host networking`. |
|
| 41 |
+ |
|
| 42 |
+### verify that the plugin has correctly started |
|
| 43 |
+##### by looking at the ENABLED column. (The value should be true) |
|
| 44 |
+ |
|
| 45 |
+```bash |
|
| 46 |
+$ docker plugin ls |
|
| 47 |
+NAME TAG ENABLED |
|
| 48 |
+vieux/sshfs latest true |
|
| 49 |
+``` |
|
| 50 |
+ |
|
| 51 |
+### create a volume using the plugin installed above |
|
| 52 |
+ |
|
| 53 |
+```bash |
|
| 54 |
+$ docker volume create -d vieux/sshfs --name sshvolume -o sshcmd=user@1.2.3.4:/remote |
|
| 55 |
+sshvolume |
|
| 56 |
+``` |
|
| 57 |
+ |
|
| 58 |
+### use the volume created above |
|
| 59 |
+ |
|
| 60 |
+```bash |
|
| 61 |
+$ docker run -v sshvolume:/data busybox ls /data |
|
| 62 |
+<content of /remote on machine 1.2.3.4> |
|
| 63 |
+``` |
|
| 64 |
+ |
|
| 65 |
+### verify that the plugin was created successfully |
|
| 66 |
+ |
|
| 67 |
+```bash |
|
| 68 |
+$ docker volume ls |
|
| 69 |
+DRIVER NAME |
|
| 70 |
+vieux/sshfs sshvolume |
|
| 71 |
+``` |
|
| 72 |
+ |
|
| 73 |
+It’s also possible to stop a plugin with the `docker plugin disable` command and to remove a plugin with `docker plugin remove`. |
|
| 74 |
+ |
|
| 75 |
+See the [command line reference](../engine/reference/commandline/) for more information. |
|
| 76 |
+ |
|
| 77 |
+## How to create a plugin |
|
| 78 |
+ |
|
| 79 |
+The creation of plugin is currently a manual process, in the future release, a command such as `docker plugin build` will be added to automate the process. So here we are going to describe the format of an existing enabled plugin, to create a plugin you have to manually craft all those files by hand. |
|
| 80 |
+ |
|
| 81 |
+Plugins are stored in `/var/lib/docker/plugins`. See this example: |
|
| 82 |
+ |
|
| 83 |
+```bash |
|
| 84 |
+# ls -la /var/lib/docker/plugins |
|
| 85 |
+total 20 |
|
| 86 |
+drwx------ 4 root root 4096 Aug 8 18:03 . |
|
| 87 |
+drwx--x--x 12 root root 4096 Aug 8 17:53 .. |
|
| 88 |
+drwxr-xr-x 3 root root 4096 Aug 8 17:56 cd851ce43a403 |
|
| 89 |
+-rw------- 1 root root 2107 Aug 8 18:03 plugins.json |
|
| 90 |
+``` |
|
| 91 |
+ |
|
| 92 |
+The file `plugins.json` is an inventory of all installed plugins, see an example of the content: |
|
| 93 |
+ |
|
| 94 |
+```bash |
|
| 95 |
+# cat plugins.json |
|
| 96 |
+{
|
|
| 97 |
+ "cd851ce43a403": {
|
|
| 98 |
+ "plugin": {
|
|
| 99 |
+ "Manifest": {
|
|
| 100 |
+ "Args": {
|
|
| 101 |
+ "Value": null, |
|
| 102 |
+ "Settable": null, |
|
| 103 |
+ "Description": "", |
|
| 104 |
+ "Name": "" |
|
| 105 |
+ }, |
|
| 106 |
+ "Env": null, |
|
| 107 |
+ "Devices": null, |
|
| 108 |
+ "Mounts": null, |
|
| 109 |
+ "Capabilities": [ |
|
| 110 |
+ "CAP_SYS_ADMIN" |
|
| 111 |
+ ], |
|
| 112 |
+ "ManifestVersion": "v0.1", |
|
| 113 |
+ "Description": "sshFS plugin for Docker", |
|
| 114 |
+ "Documentation": "https://docs.docker.com/engine/extend/plugins/", |
|
| 115 |
+ "Interface": {
|
|
| 116 |
+ "Socket": "sshfs.sock", |
|
| 117 |
+ "Types": [ |
|
| 118 |
+ "docker.volumedriver/1.0" |
|
| 119 |
+ ] |
|
| 120 |
+ }, |
|
| 121 |
+ "Entrypoint": [ |
|
| 122 |
+ "/go/bin/docker-volume-sshfs" |
|
| 123 |
+ ], |
|
| 124 |
+ "Workdir": "", |
|
| 125 |
+ "User": {},
|
|
| 126 |
+ "Network": {
|
|
| 127 |
+ "Type": "host" |
|
| 128 |
+ } |
|
| 129 |
+ }, |
|
| 130 |
+ "Config": {
|
|
| 131 |
+ "Devices": null, |
|
| 132 |
+ "Args": null, |
|
| 133 |
+ "Env": [], |
|
| 134 |
+ "Mounts": [] |
|
| 135 |
+ }, |
|
| 136 |
+ "Active": true, |
|
| 137 |
+ "Tag": "latest", |
|
| 138 |
+ "Name": "vieux/sshfs", |
|
| 139 |
+ "Id": "cd851ce43a403" |
|
| 140 |
+ } |
|
| 141 |
+ } |
|
| 142 |
+} |
|
| 143 |
+``` |
|
| 144 |
+ |
|
| 145 |
+Each folder represents a plugin, for example: |
|
| 146 |
+ |
|
| 147 |
+```bash |
|
| 148 |
+# ls -la /var/lib/docker/plugins/cd851ce43a403 |
|
| 149 |
+total 12 |
|
| 150 |
+drwx------ 19 root root 4096 Aug 8 17:56 rootfs |
|
| 151 |
+-rw-r--r-- 1 root root 50 Aug 8 17:56 plugin-config.json |
|
| 152 |
+-rw------- 1 root root 347 Aug 8 17:56 manifest.json |
|
| 153 |
+``` |
|
| 154 |
+ |
|
| 155 |
+rootfs represents the root filesystem of the plugin, in this example, it was created from this Dockerfile as follows: |
|
| 156 |
+ |
|
| 157 |
+_Note: `/run/docker/plugins` is mandatory for docker to communicate with the plugin._ |
|
| 158 |
+ |
|
| 159 |
+```bash |
|
| 160 |
+$ git clone github.com/vieux/docker-volume-sshfs |
|
| 161 |
+$ cd docker-volume-sshfs |
|
| 162 |
+$ docker build -t rootfs . |
|
| 163 |
+$ id=$(docker create rootfs true) # id was cd851ce43a403 when the image was created |
|
| 164 |
+$ mkdir -p /var/lib/docker/plugins/$id/rootfs |
|
| 165 |
+$ docker export "$id" | tar -x -C /var/lib/docker/plugins/$id/rootfs |
|
| 166 |
+$ docker rm -vf "$id" |
|
| 167 |
+$ docker rmi rootfs |
|
| 168 |
+``` |
|
| 169 |
+ |
|
| 170 |
+`manifest.json` describe the plugin and `plugin-config.json` contains some runtime parameters, see for example: |
|
| 171 |
+ |
|
| 172 |
+```bash |
|
| 173 |
+# cat manifest.json |
|
| 174 |
+{
|
|
| 175 |
+ "manifestVersion": "v0.1", |
|
| 176 |
+ "description": "sshFS plugin for Docker", |
|
| 177 |
+ "documentation": "https://docs.docker.com/engine/extend/plugins/", |
|
| 178 |
+ "entrypoint": ["/go/bin/docker-volume-sshfs"], |
|
| 179 |
+ "network": {
|
|
| 180 |
+ "type": "host" |
|
| 181 |
+ }, |
|
| 182 |
+ "interface" : {
|
|
| 183 |
+ "types": ["docker.volumedriver/1.0"], |
|
| 184 |
+ "socket": "sshfs.sock" |
|
| 185 |
+ }, |
|
| 186 |
+ "capabilities": ["CAP_SYS_ADMIN"] |
|
| 187 |
+} |
|
| 188 |
+``` |
|
| 189 |
+ |
|
| 190 |
+In this example, you can see the plugin is a volume driver, requires the `CAP_SYS_ADMIN` capability, `host networking`, `/go/bin/docker-volume-sshfs` as entrypoint and is going to use `/run/docker/plugins/sshfs.sock` to communicate with the docker engine. |
|
| 191 |
+ |
|
| 192 |
+```bash |
|
| 193 |
+# cat plugin-config.json |
|
| 194 |
+{
|
|
| 195 |
+ "Devices": null, |
|
| 196 |
+ "Args": null, |
|
| 197 |
+ "Env": [], |
|
| 198 |
+ "Mounts": [] |
|
| 199 |
+} |
|
| 200 |
+``` |
|
| 201 |
+ |
|
| 202 |
+No runtime parameters are needed for this plugin. |
|
| 203 |
+ |
|
| 204 |
+Both `manifest.json` and `plugin-config.json` are part of the `plugins.json`. |
|
| 205 |
+`manifest.json` is read-only and `plugin-config.json` is read-write. |
|
| 206 |
+ |
|
| 207 |
+ |
|
| 208 |
+ |
|
| 209 |
+To sum up, here are the steps required to create a plugin today: |
|
| 210 |
+ |
|
| 211 |
+0. choose the name of the plugins, same format as images, for example `<repo_name>/<name>` |
|
| 212 |
+1. create a rootfs as showed above in `/var/lib/docker/plugins/$id/rootfs` |
|
| 213 |
+2. create manifest.json file in `/var/lib/docker/plugins/$id/` as shown above |
|
| 214 |
+3. create a `plugin-config.json` if needed, as shown above. |
|
| 215 |
+4. create or add a section to `/var/lib/docker/plugins/plugins.json` as shown above, use |
|
| 216 |
+`<user>/<name>` as “Name” and `$id` as “Id” |
|
| 217 |
+5. restart docker |
|
| 218 |
+6. `docker plugin ls` |
|
| 219 |
+ a. if your plugin is listed as `ENABLED=true`, go to 7. |
|
| 220 |
+ b. if the plugins is not listed or listed as `ENABLED=false` something went wrong, look at the daemon logs. |
|
| 221 |
+7. if not logged in already, use `docker login` to authenticate against a registry. |
|
| 222 |
+8. push the plugin with `docker plugin push <repo_name>/<name>` |
|
| 223 |
+ |
|
| 224 |
+ |
| 0 | 225 |
deleted file mode 100644 |
| ... | ... |
@@ -1,188 +0,0 @@ |
| 1 |
-<!--[metadata]> |
|
| 2 |
-+++ |
|
| 3 |
-title = "Plugins API" |
|
| 4 |
-description = "How to write Docker plugins extensions " |
|
| 5 |
-keywords = ["API, Usage, plugins, documentation, developer"] |
|
| 6 |
-[menu.main] |
|
| 7 |
-parent = "engine_extend" |
|
| 8 |
-weight=1 |
|
| 9 |
-+++ |
|
| 10 |
-<![end-metadata]--> |
|
| 11 |
- |
|
| 12 |
-# Docker Plugin API |
|
| 13 |
- |
|
| 14 |
-Docker plugins are out-of-process extensions which add capabilities to the |
|
| 15 |
-Docker Engine. |
|
| 16 |
- |
|
| 17 |
-This page is intended for people who want to develop their own Docker plugin. |
|
| 18 |
-If you just want to learn about or use Docker plugins, look |
|
| 19 |
-[here](plugins.md). |
|
| 20 |
- |
|
| 21 |
-## What plugins are |
|
| 22 |
- |
|
| 23 |
-A plugin is a process running on the same or a different host as the docker daemon, |
|
| 24 |
-which registers itself by placing a file on the same docker host in one of the plugin |
|
| 25 |
-directories described in [Plugin discovery](#plugin-discovery). |
|
| 26 |
- |
|
| 27 |
-Plugins have human-readable names, which are short, lowercase strings. For |
|
| 28 |
-example, `flocker` or `weave`. |
|
| 29 |
- |
|
| 30 |
-Plugins can run inside or outside containers. Currently running them outside |
|
| 31 |
-containers is recommended. |
|
| 32 |
- |
|
| 33 |
-## Plugin discovery |
|
| 34 |
- |
|
| 35 |
-Docker discovers plugins by looking for them in the plugin directory whenever a |
|
| 36 |
-user or container tries to use one by name. |
|
| 37 |
- |
|
| 38 |
-There are three types of files which can be put in the plugin directory. |
|
| 39 |
- |
|
| 40 |
-* `.sock` files are UNIX domain sockets. |
|
| 41 |
-* `.spec` files are text files containing a URL, such as `unix:///other.sock` or `tcp://localhost:8080`. |
|
| 42 |
-* `.json` files are text files containing a full json specification for the plugin. |
|
| 43 |
- |
|
| 44 |
-Plugins with UNIX domain socket files must run on the same docker host, whereas |
|
| 45 |
-plugins with spec or json files can run on a different host if a remote URL is specified. |
|
| 46 |
- |
|
| 47 |
-UNIX domain socket files must be located under `/run/docker/plugins`, whereas |
|
| 48 |
-spec files can be located either under `/etc/docker/plugins` or `/usr/lib/docker/plugins`. |
|
| 49 |
- |
|
| 50 |
-The name of the file (excluding the extension) determines the plugin name. |
|
| 51 |
- |
|
| 52 |
-For example, the `flocker` plugin might create a UNIX socket at |
|
| 53 |
-`/run/docker/plugins/flocker.sock`. |
|
| 54 |
- |
|
| 55 |
-You can define each plugin into a separated subdirectory if you want to isolate definitions from each other. |
|
| 56 |
-For example, you can create the `flocker` socket under `/run/docker/plugins/flocker/flocker.sock` and only |
|
| 57 |
-mount `/run/docker/plugins/flocker` inside the `flocker` container. |
|
| 58 |
- |
|
| 59 |
-Docker always searches for unix sockets in `/run/docker/plugins` first. It checks for spec or json files under |
|
| 60 |
-`/etc/docker/plugins` and `/usr/lib/docker/plugins` if the socket doesn't exist. The directory scan stops as |
|
| 61 |
-soon as it finds the first plugin definition with the given name. |
|
| 62 |
- |
|
| 63 |
-### JSON specification |
|
| 64 |
- |
|
| 65 |
-This is the JSON format for a plugin: |
|
| 66 |
- |
|
| 67 |
-```json |
|
| 68 |
-{
|
|
| 69 |
- "Name": "plugin-example", |
|
| 70 |
- "Addr": "https://example.com/docker/plugin", |
|
| 71 |
- "TLSConfig": {
|
|
| 72 |
- "InsecureSkipVerify": false, |
|
| 73 |
- "CAFile": "/usr/shared/docker/certs/example-ca.pem", |
|
| 74 |
- "CertFile": "/usr/shared/docker/certs/example-cert.pem", |
|
| 75 |
- "KeyFile": "/usr/shared/docker/certs/example-key.pem", |
|
| 76 |
- } |
|
| 77 |
-} |
|
| 78 |
-``` |
|
| 79 |
- |
|
| 80 |
-The `TLSConfig` field is optional and TLS will only be verified if this configuration is present. |
|
| 81 |
- |
|
| 82 |
-## Plugin lifecycle |
|
| 83 |
- |
|
| 84 |
-Plugins should be started before Docker, and stopped after Docker. For |
|
| 85 |
-example, when packaging a plugin for a platform which supports `systemd`, you |
|
| 86 |
-might use [`systemd` dependencies]( |
|
| 87 |
-http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Before=) to |
|
| 88 |
-manage startup and shutdown order. |
|
| 89 |
- |
|
| 90 |
-When upgrading a plugin, you should first stop the Docker daemon, upgrade the |
|
| 91 |
-plugin, then start Docker again. |
|
| 92 |
- |
|
| 93 |
-## Plugin activation |
|
| 94 |
- |
|
| 95 |
-When a plugin is first referred to -- either by a user referring to it by name |
|
| 96 |
-(e.g. `docker run --volume-driver=foo`) or a container already configured to |
|
| 97 |
-use a plugin being started -- Docker looks for the named plugin in the plugin |
|
| 98 |
-directory and activates it with a handshake. See Handshake API below. |
|
| 99 |
- |
|
| 100 |
-Plugins are *not* activated automatically at Docker daemon startup. Rather, |
|
| 101 |
-they are activated only lazily, or on-demand, when they are needed. |
|
| 102 |
- |
|
| 103 |
-## Systemd socket activation |
|
| 104 |
- |
|
| 105 |
-Plugins may also be socket activated by `systemd`. The official [Plugins helpers](https://github.com/docker/go-plugins-helpers) |
|
| 106 |
-natively supports socket activation. In order for a plugin to be socket activated it needs |
|
| 107 |
-a `service` file and a `socket` file. |
|
| 108 |
- |
|
| 109 |
-The `service` file (for example `/lib/systemd/system/your-plugin.service`): |
|
| 110 |
- |
|
| 111 |
-``` |
|
| 112 |
-[Unit] |
|
| 113 |
-Description=Your plugin |
|
| 114 |
-Before=docker.service |
|
| 115 |
-After=network.target your-plugin.socket |
|
| 116 |
-Requires=your-plugin.socket docker.service |
|
| 117 |
- |
|
| 118 |
-[Service] |
|
| 119 |
-ExecStart=/usr/lib/docker/your-plugin |
|
| 120 |
- |
|
| 121 |
-[Install] |
|
| 122 |
-WantedBy=multi-user.target |
|
| 123 |
-``` |
|
| 124 |
-The `socket` file (for example `/lib/systemd/system/your-plugin.socket`): |
|
| 125 |
-``` |
|
| 126 |
-[Unit] |
|
| 127 |
-Description=Your plugin |
|
| 128 |
- |
|
| 129 |
-[Socket] |
|
| 130 |
-ListenStream=/run/docker/plugins/your-plugin.sock |
|
| 131 |
- |
|
| 132 |
-[Install] |
|
| 133 |
-WantedBy=sockets.target |
|
| 134 |
-``` |
|
| 135 |
- |
|
| 136 |
-This will allow plugins to be actually started when the Docker daemon connects to |
|
| 137 |
-the sockets they're listening on (for instance the first time the daemon uses them |
|
| 138 |
-or if one of the plugin goes down accidentally). |
|
| 139 |
- |
|
| 140 |
-## API design |
|
| 141 |
- |
|
| 142 |
-The Plugin API is RPC-style JSON over HTTP, much like webhooks. |
|
| 143 |
- |
|
| 144 |
-Requests flow *from* the Docker daemon *to* the plugin. So the plugin needs to |
|
| 145 |
-implement an HTTP server and bind this to the UNIX socket mentioned in the |
|
| 146 |
-"plugin discovery" section. |
|
| 147 |
- |
|
| 148 |
-All requests are HTTP `POST` requests. |
|
| 149 |
- |
|
| 150 |
-The API is versioned via an Accept header, which currently is always set to |
|
| 151 |
-`application/vnd.docker.plugins.v1+json`. |
|
| 152 |
- |
|
| 153 |
-## Handshake API |
|
| 154 |
- |
|
| 155 |
-Plugins are activated via the following "handshake" API call. |
|
| 156 |
- |
|
| 157 |
-### /Plugin.Activate |
|
| 158 |
- |
|
| 159 |
-**Request:** empty body |
|
| 160 |
- |
|
| 161 |
-**Response:** |
|
| 162 |
-``` |
|
| 163 |
-{
|
|
| 164 |
- "Implements": ["VolumeDriver"] |
|
| 165 |
-} |
|
| 166 |
-``` |
|
| 167 |
- |
|
| 168 |
-Responds with a list of Docker subsystems which this plugin implements. |
|
| 169 |
-After activation, the plugin will then be sent events from this subsystem. |
|
| 170 |
- |
|
| 171 |
-Possible values are: |
|
| 172 |
- |
|
| 173 |
-* [`authz`](plugins_authorization.md) |
|
| 174 |
-* [`NetworkDriver`](plugins_network.md) |
|
| 175 |
-* [`VolumeDriver`](plugins_volume.md) |
|
| 176 |
- |
|
| 177 |
- |
|
| 178 |
-## Plugin retries |
|
| 179 |
- |
|
| 180 |
-Attempts to call a method on a plugin are retried with an exponential backoff |
|
| 181 |
-for up to 30 seconds. This may help when packaging plugins as containers, since |
|
| 182 |
-it gives plugin containers a chance to start up before failing any user |
|
| 183 |
-containers which depend on them. |
|
| 184 |
- |
|
| 185 |
-## Plugins helpers |
|
| 186 |
- |
|
| 187 |
-To ease plugins development, we're providing an `sdk` for each kind of plugins |
|
| 188 |
-currently supported by Docker at [docker/go-plugins-helpers](https://github.com/docker/go-plugins-helpers). |
| 189 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,87 +0,0 @@ |
| 1 |
-<!--[metadata]> |
|
| 2 |
-+++ |
|
| 3 |
-title = "Extending Engine with plugins" |
|
| 4 |
-description = "How to add additional functionality to Docker with plugins extensions" |
|
| 5 |
-keywords = ["Examples, Usage, plugins, docker, documentation, user guide"] |
|
| 6 |
-[menu.main] |
|
| 7 |
-parent = "engine_extend" |
|
| 8 |
-weight=-1 |
|
| 9 |
-+++ |
|
| 10 |
-<![end-metadata]--> |
|
| 11 |
- |
|
| 12 |
-# Understand Engine plugins |
|
| 13 |
- |
|
| 14 |
-You can extend the capabilities of the Docker Engine by loading third-party |
|
| 15 |
-plugins. This page explains the types of plugins and provides links to several |
|
| 16 |
-volume and network plugins for Docker. |
|
| 17 |
- |
|
| 18 |
-## Types of plugins |
|
| 19 |
- |
|
| 20 |
-Plugins extend Docker's functionality. They come in specific types. For |
|
| 21 |
-example, a [volume plugin](plugins_volume.md) might enable Docker |
|
| 22 |
-volumes to persist across multiple Docker hosts and a |
|
| 23 |
-[network plugin](plugins_network.md) might provide network plumbing. |
|
| 24 |
- |
|
| 25 |
-Currently Docker supports authorization, volume and network driver plugins. In the future it |
|
| 26 |
-will support additional plugin types. |
|
| 27 |
- |
|
| 28 |
-## Installing a plugin |
|
| 29 |
- |
|
| 30 |
-Follow the instructions in the plugin's documentation. |
|
| 31 |
- |
|
| 32 |
-## Finding a plugin |
|
| 33 |
- |
|
| 34 |
-The sections below provide an inexhaustive overview of available plugins. |
|
| 35 |
- |
|
| 36 |
-<style> |
|
| 37 |
-#DocumentationText tr td:first-child { white-space: nowrap;}
|
|
| 38 |
-</style> |
|
| 39 |
- |
|
| 40 |
-### Network plugins |
|
| 41 |
- |
|
| 42 |
-Plugin | Description |
|
| 43 |
-[Contiv Networking](https://github.com/contiv/netplugin) | An open source network plugin to provide infrastructure and security policies for a multi-tenant micro services deployment, while providing an integration to physical network for non-container workload. Contiv Networking implements the remote driver and IPAM APIs available in Docker 1.9 onwards. |
|
| 44 |
-[Kuryr Network Plugin](https://github.com/openstack/kuryr) | A network plugin is developed as part of the OpenStack Kuryr project and implements the Docker networking (libnetwork) remote driver API by utilizing Neutron, the OpenStack networking service. It includes an IPAM driver as well. |
|
| 45 |
-[Weave Network Plugin](https://www.weave.works/docs/net/latest/introducing-weave/) | A network plugin that creates a virtual network that connects your Docker containers - across multiple hosts or clouds and enables automatic discovery of applications. Weave networks are resilient, partition tolerant, secure and work in partially connected networks, and other adverse environments - all configured with delightful simplicity. |
|
| 46 |
- |
|
| 47 |
-### Volume plugins |
|
| 48 |
- |
|
| 49 |
-Plugin | Description |
|
| 50 |
-[Azure File Storage plugin](https://github.com/Azure/azurefile-dockervolumedriver) | Lets you mount Microsoft [Azure File Storage](https://azure.microsoft.com/blog/azure-file-storage-now-generally-available/) shares to Docker containers as volumes using the SMB 3.0 protocol. [Learn more](https://azure.microsoft.com/blog/persistent-docker-volumes-with-azure-file-storage/). |
|
| 51 |
-[Blockbridge plugin](https://github.com/blockbridge/blockbridge-docker-volume) | A volume plugin that provides access to an extensible set of container-based persistent storage options. It supports single and multi-host Docker environments with features that include tenant isolation, automated provisioning, encryption, secure deletion, snapshots and QoS. |
|
| 52 |
-[Contiv Volume Plugin](https://github.com/contiv/volplugin) | An open source volume plugin that provides multi-tenant, persistent, distributed storage with intent based consumption using ceph underneath. |
|
| 53 |
-[Convoy plugin](https://github.com/rancher/convoy) | A volume plugin for a variety of storage back-ends including device mapper and NFS. It's a simple standalone executable written in Go and provides the framework to support vendor-specific extensions such as snapshots, backups and restore. |
|
| 54 |
-[DRBD plugin](https://www.drbd.org/en/supported-projects/docker) | A volume plugin that provides highly available storage replicated by [DRBD](https://www.drbd.org). Data written to the docker volume is replicated in a cluster of DRBD nodes. |
|
| 55 |
-[Flocker plugin](https://clusterhq.com/docker-plugin/) | A volume plugin that provides multi-host portable volumes for Docker, enabling you to run databases and other stateful containers and move them around across a cluster of machines. |
|
| 56 |
-[gce-docker plugin](https://github.com/mcuadros/gce-docker) | A volume plugin able to attach, format and mount Google Compute [persistent-disks](https://cloud.google.com/compute/docs/disks/persistent-disks). |
|
| 57 |
-[GlusterFS plugin](https://github.com/calavera/docker-volume-glusterfs) | A volume plugin that provides multi-host volumes management for Docker using GlusterFS. |
|
| 58 |
-[Horcrux Volume Plugin](https://github.com/muthu-r/horcrux) | A volume plugin that allows on-demand, version controlled access to your data. Horcrux is an open-source plugin, written in Go, and supports SCP, [Minio](https://www.minio.io) and Amazon S3. |
|
| 59 |
-[HPE 3Par Volume Plugin](https://github.com/hpe-storage/python-hpedockerplugin/) | A volume plugin that supports HPE 3Par and StoreVirtual iSCSI storage arrays. |
|
| 60 |
-[IPFS Volume Plugin](http://github.com/vdemeester/docker-volume-ipfs) | An open source volume plugin that allows using an [ipfs](https://ipfs.io/) filesystem as a volume. |
|
| 61 |
-[Keywhiz plugin](https://github.com/calavera/docker-volume-keywhiz) | A plugin that provides credentials and secret management using Keywhiz as a central repository. |
|
| 62 |
-[Local Persist Plugin](https://github.com/CWSpear/local-persist) | A volume plugin that extends the default `local` driver's functionality by allowing you specify a mountpoint anywhere on the host, which enables the files to *always persist*, even if the volume is removed via `docker volume rm`. |
|
| 63 |
-[NetApp Plugin](https://github.com/NetApp/netappdvp) (nDVP) | A volume plugin that provides direct integration with the Docker ecosystem for the NetApp storage portfolio. The nDVP package supports the provisioning and management of storage resources from the storage platform to Docker hosts, with a robust framework for adding additional platforms in the future. |
|
| 64 |
-[Netshare plugin](https://github.com/ContainX/docker-volume-netshare) | A volume plugin that provides volume management for NFS 3/4, AWS EFS and CIFS file systems. |
|
| 65 |
-[OpenStorage Plugin](https://github.com/libopenstorage/openstorage) | A cluster-aware volume plugin that provides volume management for file and block storage solutions. It implements a vendor neutral specification for implementing extensions such as CoS, encryption, and snapshots. It has example drivers based on FUSE, NFS, NBD and EBS to name a few. |
|
| 66 |
-[Quobyte Volume Plugin](https://github.com/quobyte/docker-volume) | A volume plugin that connects Docker to [Quobyte](http://www.quobyte.com/containers)'s data center file system, a general-purpose scalable and fault-tolerant storage platform. |
|
| 67 |
-[REX-Ray plugin](https://github.com/emccode/rexray) | A volume plugin which is written in Go and provides advanced storage functionality for many platforms including VirtualBox, EC2, Google Compute Engine, OpenStack, and EMC. |
|
| 68 |
-[Virtuozzo Storage and Ploop plugin](https://github.com/virtuozzo/docker-volume-ploop) | A volume plugin with support for Virtuozzo Storage distributed cloud file system as well as ploop devices. |
|
| 69 |
-[VMware vSphere Storage Plugin](https://github.com/vmware/docker-volume-vsphere) | Docker Volume Driver for vSphere enables customers to address persistent storage requirements for Docker containers in vSphere environments. |
|
| 70 |
- |
|
| 71 |
-### Authorization plugins |
|
| 72 |
- |
|
| 73 |
- Plugin | Description |
|
| 74 |
- [Twistlock AuthZ Broker](https://github.com/twistlock/authz) | A basic extendable authorization plugin that runs directly on the host or inside a container. This plugin allows you to define user policies that it evaluates during authorization. Basic authorization is provided if Docker daemon is started with the --tlsverify flag (username is extracted from the certificate common name). |
|
| 75 |
- |
|
| 76 |
-## Troubleshooting a plugin |
|
| 77 |
- |
|
| 78 |
-If you are having problems with Docker after loading a plugin, ask the authors |
|
| 79 |
-of the plugin for help. The Docker team may not be able to assist you. |
|
| 80 |
- |
|
| 81 |
-## Writing a plugin |
|
| 82 |
- |
|
| 83 |
-If you are interested in writing a plugin for Docker, or seeing how they work |
|
| 84 |
-under the hood, see the [docker plugins reference](plugin_api.md). |
| 85 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,252 +0,0 @@ |
| 1 |
-<!--[metadata]> |
|
| 2 |
-+++ |
|
| 3 |
-title = "Access authorization plugin" |
|
| 4 |
-description = "How to create authorization plugins to manage access control to your Docker daemon." |
|
| 5 |
-keywords = ["security, authorization, authentication, docker, documentation, plugin, extend"] |
|
| 6 |
-aliases = ["/engine/extend/authorization/"] |
|
| 7 |
-[menu.main] |
|
| 8 |
-parent = "engine_extend" |
|
| 9 |
-weight = -1 |
|
| 10 |
-+++ |
|
| 11 |
-<![end-metadata]--> |
|
| 12 |
- |
|
| 13 |
- |
|
| 14 |
-# Create an authorization plugin |
|
| 15 |
- |
|
| 16 |
-Docker's out-of-the-box authorization model is all or nothing. Any user with |
|
| 17 |
-permission to access the Docker daemon can run any Docker client command. The |
|
| 18 |
-same is true for callers using Docker's remote API to contact the daemon. If you |
|
| 19 |
-require greater access control, you can create authorization plugins and add |
|
| 20 |
-them to your Docker daemon configuration. Using an authorization plugin, a |
|
| 21 |
-Docker administrator can configure granular access policies for managing access |
|
| 22 |
-to Docker daemon. |
|
| 23 |
- |
|
| 24 |
-Anyone with the appropriate skills can develop an authorization plugin. These |
|
| 25 |
-skills, at their most basic, are knowledge of Docker, understanding of REST, and |
|
| 26 |
-sound programming knowledge. This document describes the architecture, state, |
|
| 27 |
-and methods information available to an authorization plugin developer. |
|
| 28 |
- |
|
| 29 |
-## Basic principles |
|
| 30 |
- |
|
| 31 |
-Docker's [plugin infrastructure](plugin_api.md) enables |
|
| 32 |
-extending Docker by loading, removing and communicating with |
|
| 33 |
-third-party components using a generic API. The access authorization subsystem |
|
| 34 |
-was built using this mechanism. |
|
| 35 |
- |
|
| 36 |
-Using this subsystem, you don't need to rebuild the Docker daemon to add an |
|
| 37 |
-authorization plugin. You can add a plugin to an installed Docker daemon. You do |
|
| 38 |
-need to restart the Docker daemon to add a new plugin. |
|
| 39 |
- |
|
| 40 |
-An authorization plugin approves or denies requests to the Docker daemon based |
|
| 41 |
-on both the current authentication context and the command context. The |
|
| 42 |
-authentication context contains all user details and the authentication method. |
|
| 43 |
-The command context contains all the relevant request data. |
|
| 44 |
- |
|
| 45 |
-Authorization plugins must follow the rules described in [Docker Plugin API](plugin_api.md). |
|
| 46 |
-Each plugin must reside within directories described under the |
|
| 47 |
-[Plugin discovery](plugin_api.md#plugin-discovery) section. |
|
| 48 |
- |
|
| 49 |
-**Note**: the abbreviations `AuthZ` and `AuthN` mean authorization and authentication |
|
| 50 |
-respectively. |
|
| 51 |
- |
|
| 52 |
-## Default user authorization mechanism |
|
| 53 |
- |
|
| 54 |
-If TLS is enabled in the [Docker daemon](../security/https.md), the default user authorization flow extracts the user details from the certificate subject name. |
|
| 55 |
-That is, the `User` field is set to the client certificate subject common name, and the `AuthenticationMethod` field is set to `TLS`. |
|
| 56 |
- |
|
| 57 |
-## Basic architecture |
|
| 58 |
- |
|
| 59 |
-You are responsible for registering your plugin as part of the Docker daemon |
|
| 60 |
-startup. You can install multiple plugins and chain them together. This chain |
|
| 61 |
-can be ordered. Each request to the daemon passes in order through the chain. |
|
| 62 |
-Only when all the plugins grant access to the resource, is the access granted. |
|
| 63 |
- |
|
| 64 |
-When an HTTP request is made to the Docker daemon through the CLI or via the |
|
| 65 |
-remote API, the authentication subsystem passes the request to the installed |
|
| 66 |
-authentication plugin(s). The request contains the user (caller) and command |
|
| 67 |
-context. The plugin is responsible for deciding whether to allow or deny the |
|
| 68 |
-request. |
|
| 69 |
- |
|
| 70 |
-The sequence diagrams below depict an allow and deny authorization flow: |
|
| 71 |
- |
|
| 72 |
- |
|
| 73 |
- |
|
| 74 |
- |
|
| 75 |
- |
|
| 76 |
-Each request sent to the plugin includes the authenticated user, the HTTP |
|
| 77 |
-headers, and the request/response body. Only the user name and the |
|
| 78 |
-authentication method used are passed to the plugin. Most importantly, no user |
|
| 79 |
-credentials or tokens are passed. Finally, not all request/response bodies |
|
| 80 |
-are sent to the authorization plugin. Only those request/response bodies where |
|
| 81 |
-the `Content-Type` is either `text/*` or `application/json` are sent. |
|
| 82 |
- |
|
| 83 |
-For commands that can potentially hijack the HTTP connection (`HTTP |
|
| 84 |
-Upgrade`), such as `exec`, the authorization plugin is only called for the |
|
| 85 |
-initial HTTP requests. Once the plugin approves the command, authorization is |
|
| 86 |
-not applied to the rest of the flow. Specifically, the streaming data is not |
|
| 87 |
-passed to the authorization plugins. For commands that return chunked HTTP |
|
| 88 |
-response, such as `logs` and `events`, only the HTTP request is sent to the |
|
| 89 |
-authorization plugins. |
|
| 90 |
- |
|
| 91 |
-During request/response processing, some authorization flows might |
|
| 92 |
-need to do additional queries to the Docker daemon. To complete such flows, |
|
| 93 |
-plugins can call the daemon API similar to a regular user. To enable these |
|
| 94 |
-additional queries, the plugin must provide the means for an administrator to |
|
| 95 |
-configure proper authentication and security policies. |
|
| 96 |
- |
|
| 97 |
-## Docker client flows |
|
| 98 |
- |
|
| 99 |
-To enable and configure the authorization plugin, the plugin developer must |
|
| 100 |
-support the Docker client interactions detailed in this section. |
|
| 101 |
- |
|
| 102 |
-### Setting up Docker daemon |
|
| 103 |
- |
|
| 104 |
-Enable the authorization plugin with a dedicated command line flag in the |
|
| 105 |
-`--authorization-plugin=PLUGIN_ID` format. The flag supplies a `PLUGIN_ID` |
|
| 106 |
-value. This value can be the plugin’s socket or a path to a specification file. |
|
| 107 |
-Authorization plugins can be loaded without restarting the daemon. Refer |
|
| 108 |
-to the [`dockerd` documentation](../reference/commandline/dockerd.md#configuration-reloading) for more information. |
|
| 109 |
- |
|
| 110 |
-```bash |
|
| 111 |
-$ docker daemon --authorization-plugin=plugin1 --authorization-plugin=plugin2,... |
|
| 112 |
-``` |
|
| 113 |
- |
|
| 114 |
-Docker's authorization subsystem supports multiple `--authorization-plugin` parameters. |
|
| 115 |
- |
|
| 116 |
-### Calling authorized command (allow) |
|
| 117 |
- |
|
| 118 |
-```bash |
|
| 119 |
-$ docker pull centos |
|
| 120 |
-... |
|
| 121 |
-f1b10cd84249: Pull complete |
|
| 122 |
-... |
|
| 123 |
-``` |
|
| 124 |
- |
|
| 125 |
-### Calling unauthorized command (deny) |
|
| 126 |
- |
|
| 127 |
-```bash |
|
| 128 |
-$ docker pull centos |
|
| 129 |
-... |
|
| 130 |
-docker: Error response from daemon: authorization denied by plugin PLUGIN_NAME: volumes are not allowed. |
|
| 131 |
-``` |
|
| 132 |
- |
|
| 133 |
-### Error from plugins |
|
| 134 |
- |
|
| 135 |
-```bash |
|
| 136 |
-$ docker pull centos |
|
| 137 |
-... |
|
| 138 |
-docker: Error response from daemon: plugin PLUGIN_NAME failed with error: AuthZPlugin.AuthZReq: Cannot connect to the Docker daemon. Is the docker daemon running on this host?. |
|
| 139 |
-``` |
|
| 140 |
- |
|
| 141 |
-## API schema and implementation |
|
| 142 |
- |
|
| 143 |
-In addition to Docker's standard plugin registration method, each plugin |
|
| 144 |
-should implement the following two methods: |
|
| 145 |
- |
|
| 146 |
-* `/AuthZPlugin.AuthZReq` This authorize request method is called before the Docker daemon processes the client request. |
|
| 147 |
- |
|
| 148 |
-* `/AuthZPlugin.AuthZRes` This authorize response method is called before the response is returned from Docker daemon to the client. |
|
| 149 |
- |
|
| 150 |
-#### /AuthZPlugin.AuthZReq |
|
| 151 |
- |
|
| 152 |
-**Request**: |
|
| 153 |
- |
|
| 154 |
-```json |
|
| 155 |
-{
|
|
| 156 |
- "User": "The user identification", |
|
| 157 |
- "UserAuthNMethod": "The authentication method used", |
|
| 158 |
- "RequestMethod": "The HTTP method", |
|
| 159 |
- "RequestURI": "The HTTP request URI", |
|
| 160 |
- "RequestBody": "Byte array containing the raw HTTP request body", |
|
| 161 |
- "RequestHeader": "Byte array containing the raw HTTP request header as a map[string][]string " |
|
| 162 |
-} |
|
| 163 |
-``` |
|
| 164 |
- |
|
| 165 |
-**Response**: |
|
| 166 |
- |
|
| 167 |
-```json |
|
| 168 |
-{
|
|
| 169 |
- "Allow": "Determined whether the user is allowed or not", |
|
| 170 |
- "Msg": "The authorization message", |
|
| 171 |
- "Err": "The error message if things go wrong" |
|
| 172 |
-} |
|
| 173 |
-``` |
|
| 174 |
-#### /AuthZPlugin.AuthZRes |
|
| 175 |
- |
|
| 176 |
-**Request**: |
|
| 177 |
- |
|
| 178 |
-```json |
|
| 179 |
-{
|
|
| 180 |
- "User": "The user identification", |
|
| 181 |
- "UserAuthNMethod": "The authentication method used", |
|
| 182 |
- "RequestMethod": "The HTTP method", |
|
| 183 |
- "RequestURI": "The HTTP request URI", |
|
| 184 |
- "RequestBody": "Byte array containing the raw HTTP request body", |
|
| 185 |
- "RequestHeader": "Byte array containing the raw HTTP request header as a map[string][]string", |
|
| 186 |
- "ResponseBody": "Byte array containing the raw HTTP response body", |
|
| 187 |
- "ResponseHeader": "Byte array containing the raw HTTP response header as a map[string][]string", |
|
| 188 |
- "ResponseStatusCode":"Response status code" |
|
| 189 |
-} |
|
| 190 |
-``` |
|
| 191 |
- |
|
| 192 |
-**Response**: |
|
| 193 |
- |
|
| 194 |
-```json |
|
| 195 |
-{
|
|
| 196 |
- "Allow": "Determined whether the user is allowed or not", |
|
| 197 |
- "Msg": "The authorization message", |
|
| 198 |
- "Err": "The error message if things go wrong" |
|
| 199 |
-} |
|
| 200 |
-``` |
|
| 201 |
- |
|
| 202 |
-### Request authorization |
|
| 203 |
- |
|
| 204 |
-Each plugin must support two request authorization messages formats, one from the daemon to the plugin and then from the plugin to the daemon. The tables below detail the content expected in each message. |
|
| 205 |
- |
|
| 206 |
-#### Daemon -> Plugin |
|
| 207 |
- |
|
| 208 |
-Name | Type | Description |
|
| 209 |
-User | string | The user identification |
|
| 210 |
-Authentication method | string | The authentication method used |
|
| 211 |
-Request method | enum | The HTTP method (GET/DELETE/POST) |
|
| 212 |
-Request URI | string | The HTTP request URI including API version (e.g., v.1.17/containers/json) |
|
| 213 |
-Request headers | map[string]string | Request headers as key value pairs (without the authorization header) |
|
| 214 |
-Request body | []byte | Raw request body |
|
| 215 |
- |
|
| 216 |
- |
|
| 217 |
-#### Plugin -> Daemon |
|
| 218 |
- |
|
| 219 |
-Name | Type | Description |
|
| 220 |
-Allow | bool | Boolean value indicating whether the request is allowed or denied |
|
| 221 |
-Msg | string | Authorization message (will be returned to the client in case the access is denied) |
|
| 222 |
-Err | string | Error message (will be returned to the client in case the plugin encounter an error. The string value supplied may appear in logs, so should not include confidential information) |
|
| 223 |
- |
|
| 224 |
-### Response authorization |
|
| 225 |
- |
|
| 226 |
-The plugin must support two authorization messages formats, one from the daemon to the plugin and then from the plugin to the daemon. The tables below detail the content expected in each message. |
|
| 227 |
- |
|
| 228 |
-#### Daemon -> Plugin |
|
| 229 |
- |
|
| 230 |
- |
|
| 231 |
-Name | Type | Description |
|
| 232 |
-User | string | The user identification |
|
| 233 |
-Authentication method | string | The authentication method used |
|
| 234 |
-Request method | string | The HTTP method (GET/DELETE/POST) |
|
| 235 |
-Request URI | string | The HTTP request URI including API version (e.g., v.1.17/containers/json) |
|
| 236 |
-Request headers | map[string]string | Request headers as key value pairs (without the authorization header) |
|
| 237 |
-Request body | []byte | Raw request body |
|
| 238 |
-Response status code | int | Status code from the docker daemon |
|
| 239 |
-Response headers | map[string]string | Response headers as key value pairs |
|
| 240 |
-Response body | []byte | Raw docker daemon response body |
|
| 241 |
- |
|
| 242 |
- |
|
| 243 |
-#### Plugin -> Daemon |
|
| 244 |
- |
|
| 245 |
-Name | Type | Description |
|
| 246 |
-Allow | bool | Boolean value indicating whether the response is allowed or denied |
|
| 247 |
-Msg | string | Authorization message (will be returned to the client in case the access is denied) |
|
| 248 |
-Err | string | Error message (will be returned to the client in case the plugin encounter an error. The string value supplied may appear in logs, so should not include confidential information) |
| 249 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,68 +0,0 @@ |
| 1 |
-<!--[metadata]> |
|
| 2 |
-+++ |
|
| 3 |
-title = "Docker network driver plugins" |
|
| 4 |
-description = "Network driver plugins." |
|
| 5 |
-keywords = ["Examples, Usage, plugins, docker, documentation, user guide"] |
|
| 6 |
-[menu.main] |
|
| 7 |
-parent = "engine_extend" |
|
| 8 |
-+++ |
|
| 9 |
-<![end-metadata]--> |
|
| 10 |
- |
|
| 11 |
-# Engine network driver plugins |
|
| 12 |
- |
|
| 13 |
-Docker Engine network plugins enable Engine deployments to be extended to |
|
| 14 |
-support a wide range of networking technologies, such as VXLAN, IPVLAN, MACVLAN |
|
| 15 |
-or something completely different. Network driver plugins are supported via the |
|
| 16 |
-LibNetwork project. Each plugin is implemented as a "remote driver" for |
|
| 17 |
-LibNetwork, which shares plugin infrastructure with Engine. Effectively, network |
|
| 18 |
-driver plugins are activated in the same way as other plugins, and use the same |
|
| 19 |
-kind of protocol. |
|
| 20 |
- |
|
| 21 |
-## Network driver plugins and swarm mode |
|
| 22 |
- |
|
| 23 |
-Docker 1.12 adds support for cluster management and orchestration called |
|
| 24 |
-[swarm mode](../swarm/index.md). Docker Engine running in swarm mode currently |
|
| 25 |
-only supports the built-in overlay driver for networking. Therefore existing |
|
| 26 |
-networking plugins will not work in swarm mode. |
|
| 27 |
- |
|
| 28 |
-When you run Docker Engine outside of swarm mode, all networking plugins that |
|
| 29 |
-worked in Docker 1.11 will continue to function normally. They do not require |
|
| 30 |
-any modification. |
|
| 31 |
- |
|
| 32 |
-## Using network driver plugins |
|
| 33 |
- |
|
| 34 |
-The means of installing and running a network driver plugin depend on the |
|
| 35 |
-particular plugin. So, be sure to install your plugin according to the |
|
| 36 |
-instructions obtained from the plugin developer. |
|
| 37 |
- |
|
| 38 |
-Once running however, network driver plugins are used just like the built-in |
|
| 39 |
-network drivers: by being mentioned as a driver in network-oriented Docker |
|
| 40 |
-commands. For example, |
|
| 41 |
- |
|
| 42 |
- $ docker network create --driver weave mynet |
|
| 43 |
- |
|
| 44 |
-Some network driver plugins are listed in [plugins](plugins.md) |
|
| 45 |
- |
|
| 46 |
-The `mynet` network is now owned by `weave`, so subsequent commands |
|
| 47 |
-referring to that network will be sent to the plugin, |
|
| 48 |
- |
|
| 49 |
- $ docker run --network=mynet busybox top |
|
| 50 |
- |
|
| 51 |
- |
|
| 52 |
-## Write a network plugin |
|
| 53 |
- |
|
| 54 |
-Network plugins implement the [Docker plugin |
|
| 55 |
-API](https://docs.docker.com/extend/plugin_api/) and the network plugin protocol |
|
| 56 |
- |
|
| 57 |
-## Network plugin protocol |
|
| 58 |
- |
|
| 59 |
-The network driver protocol, in addition to the plugin activation call, is |
|
| 60 |
-documented as part of libnetwork: |
|
| 61 |
-[https://github.com/docker/libnetwork/blob/master/docs/remote.md](https://github.com/docker/libnetwork/blob/master/docs/remote.md). |
|
| 62 |
- |
|
| 63 |
-# Related Information |
|
| 64 |
- |
|
| 65 |
-To interact with the Docker maintainers and other interested users, see the IRC channel `#docker-network`. |
|
| 66 |
- |
|
| 67 |
-- [Docker networks feature overview](../userguide/networking/index.md) |
|
| 68 |
-- The [LibNetwork](https://github.com/docker/libnetwork) project |
| 69 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,267 +0,0 @@ |
| 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 = "engine_extend" |
|
| 8 |
-+++ |
|
| 9 |
-<![end-metadata]--> |
|
| 10 |
- |
|
| 11 |
-# Write a volume plugin |
|
| 12 |
- |
|
| 13 |
-Docker Engine volume plugins enable Engine deployments to be integrated with |
|
| 14 |
-external storage systems, such as Amazon EBS, and enable data volumes to persist |
|
| 15 |
-beyond the lifetime of a single Engine host. See the [plugin |
|
| 16 |
-documentation](plugins.md) for more information. |
|
| 17 |
- |
|
| 18 |
-## Changelog |
|
| 19 |
- |
|
| 20 |
-### 1.12.0 |
|
| 21 |
- |
|
| 22 |
-- Add `Status` field to `VolumeDriver.Get` response ([#21006](https://github.com/docker/docker/pull/21006#)) |
|
| 23 |
-- Add `VolumeDriver.Capabilities` to get capabilities of the volume driver([#22077](https://github.com/docker/docker/pull/22077)) |
|
| 24 |
- |
|
| 25 |
-### 1.10.0 |
|
| 26 |
- |
|
| 27 |
-- Add `VolumeDriver.Get` which gets the details about the volume ([#16534](https://github.com/docker/docker/pull/16534)) |
|
| 28 |
-- Add `VolumeDriver.List` which lists all volumes owned by the driver ([#16534](https://github.com/docker/docker/pull/16534)) |
|
| 29 |
- |
|
| 30 |
-### 1.8.0 |
|
| 31 |
- |
|
| 32 |
-- Initial support for volume driver plugins ([#14659](https://github.com/docker/docker/pull/14659)) |
|
| 33 |
- |
|
| 34 |
-## Command-line changes |
|
| 35 |
- |
|
| 36 |
-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: |
|
| 37 |
- |
|
| 38 |
- $ docker run -ti -v volumename:/data --volume-driver=flocker busybox sh |
|
| 39 |
- |
|
| 40 |
-This command passes the `volumename` through to the volume plugin as a |
|
| 41 |
-user-given name for the volume. The `volumename` must not begin with a `/`. |
|
| 42 |
- |
|
| 43 |
-By having the user specify a `volumename`, a plugin can associate the volume |
|
| 44 |
-with an external volume beyond the lifetime of a single container or container |
|
| 45 |
-host. This can be used, for example, to move a stateful container from one |
|
| 46 |
-server to another. |
|
| 47 |
- |
|
| 48 |
-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. |
|
| 49 |
- |
|
| 50 |
- |
|
| 51 |
-## Create a VolumeDriver |
|
| 52 |
- |
|
| 53 |
-The container creation endpoint (`/containers/create`) accepts a `VolumeDriver` |
|
| 54 |
-field of type `string` allowing to specify the name of the driver. It's default |
|
| 55 |
-value of `"local"` (the default driver for local volumes). |
|
| 56 |
- |
|
| 57 |
-## Volume plugin protocol |
|
| 58 |
- |
|
| 59 |
-If a plugin registers itself as a `VolumeDriver` when activated, then it is |
|
| 60 |
-expected to provide writeable paths on the host filesystem for the Docker |
|
| 61 |
-daemon to provide to containers to consume. |
|
| 62 |
- |
|
| 63 |
-The Docker daemon handles bind-mounting the provided paths into user |
|
| 64 |
-containers. |
|
| 65 |
- |
|
| 66 |
-> **Note**: Volume plugins should *not* write data to the `/var/lib/docker/` |
|
| 67 |
-> directory, including `/var/lib/docker/volumes`. The `/var/lib/docker/` |
|
| 68 |
-> directory is reserved for Docker. |
|
| 69 |
- |
|
| 70 |
-### /VolumeDriver.Create |
|
| 71 |
- |
|
| 72 |
-**Request**: |
|
| 73 |
-```json |
|
| 74 |
-{
|
|
| 75 |
- "Name": "volume_name", |
|
| 76 |
- "Opts": {}
|
|
| 77 |
-} |
|
| 78 |
-``` |
|
| 79 |
- |
|
| 80 |
-Instruct the plugin that the user wants to create a volume, given a user |
|
| 81 |
-specified volume name. The plugin does not need to actually manifest the |
|
| 82 |
-volume on the filesystem yet (until Mount is called). |
|
| 83 |
-Opts is a map of driver specific options passed through from the user request. |
|
| 84 |
- |
|
| 85 |
-**Response**: |
|
| 86 |
-```json |
|
| 87 |
-{
|
|
| 88 |
- "Err": "" |
|
| 89 |
-} |
|
| 90 |
-``` |
|
| 91 |
- |
|
| 92 |
-Respond with a string error if an error occurred. |
|
| 93 |
- |
|
| 94 |
-### /VolumeDriver.Remove |
|
| 95 |
- |
|
| 96 |
-**Request**: |
|
| 97 |
-```json |
|
| 98 |
-{
|
|
| 99 |
- "Name": "volume_name" |
|
| 100 |
-} |
|
| 101 |
-``` |
|
| 102 |
- |
|
| 103 |
-Delete the specified volume from disk. This request is issued when a user invokes `docker rm -v` to remove volumes associated with a container. |
|
| 104 |
- |
|
| 105 |
-**Response**: |
|
| 106 |
-```json |
|
| 107 |
-{
|
|
| 108 |
- "Err": "" |
|
| 109 |
-} |
|
| 110 |
-``` |
|
| 111 |
- |
|
| 112 |
-Respond with a string error if an error occurred. |
|
| 113 |
- |
|
| 114 |
-### /VolumeDriver.Mount |
|
| 115 |
- |
|
| 116 |
-**Request**: |
|
| 117 |
-```json |
|
| 118 |
-{
|
|
| 119 |
- "Name": "volume_name", |
|
| 120 |
- "ID": "b87d7442095999a92b65b3d9691e697b61713829cc0ffd1bb72e4ccd51aa4d6c" |
|
| 121 |
-} |
|
| 122 |
-``` |
|
| 123 |
- |
|
| 124 |
-Docker requires the plugin to provide a volume, given a user specified volume |
|
| 125 |
-name. This is called once per container start. If the same volume_name is requested |
|
| 126 |
-more than once, the plugin may need to keep track of each new mount request and provision |
|
| 127 |
-at the first mount request and deprovision at the last corresponding unmount request. |
|
| 128 |
- |
|
| 129 |
-`ID` is a unique ID for the caller that is requesting the mount. |
|
| 130 |
- |
|
| 131 |
-**Response**: |
|
| 132 |
-```json |
|
| 133 |
-{
|
|
| 134 |
- "Mountpoint": "/path/to/directory/on/host", |
|
| 135 |
- "Err": "" |
|
| 136 |
-} |
|
| 137 |
-``` |
|
| 138 |
- |
|
| 139 |
-Respond with the path on the host filesystem where the volume has been made |
|
| 140 |
-available, and/or a string error if an error occurred. |
|
| 141 |
- |
|
| 142 |
-### /VolumeDriver.Path |
|
| 143 |
- |
|
| 144 |
-**Request**: |
|
| 145 |
-```json |
|
| 146 |
-{
|
|
| 147 |
- "Name": "volume_name" |
|
| 148 |
-} |
|
| 149 |
-``` |
|
| 150 |
- |
|
| 151 |
-Docker needs reminding of the path to the volume on the host. |
|
| 152 |
- |
|
| 153 |
-**Response**: |
|
| 154 |
-```json |
|
| 155 |
-{
|
|
| 156 |
- "Mountpoint": "/path/to/directory/on/host", |
|
| 157 |
- "Err": "" |
|
| 158 |
-} |
|
| 159 |
-``` |
|
| 160 |
- |
|
| 161 |
-Respond with the path on the host filesystem where the volume has been made |
|
| 162 |
-available, and/or a string error if an error occurred. `Mountpoint` is optional, |
|
| 163 |
-however the plugin may be queried again later if one is not provided. |
|
| 164 |
- |
|
| 165 |
-### /VolumeDriver.Unmount |
|
| 166 |
- |
|
| 167 |
-**Request**: |
|
| 168 |
-```json |
|
| 169 |
-{
|
|
| 170 |
- "Name": "volume_name", |
|
| 171 |
- "ID": "b87d7442095999a92b65b3d9691e697b61713829cc0ffd1bb72e4ccd51aa4d6c" |
|
| 172 |
-} |
|
| 173 |
-``` |
|
| 174 |
- |
|
| 175 |
-Indication that Docker no longer is using the named volume. This is called once |
|
| 176 |
-per container stop. Plugin may deduce that it is safe to deprovision it at |
|
| 177 |
-this point. |
|
| 178 |
- |
|
| 179 |
-`ID` is a unique ID for the caller that is requesting the mount. |
|
| 180 |
- |
|
| 181 |
-**Response**: |
|
| 182 |
-```json |
|
| 183 |
-{
|
|
| 184 |
- "Err": "" |
|
| 185 |
-} |
|
| 186 |
-``` |
|
| 187 |
- |
|
| 188 |
-Respond with a string error if an error occurred. |
|
| 189 |
- |
|
| 190 |
- |
|
| 191 |
-### /VolumeDriver.Get |
|
| 192 |
- |
|
| 193 |
-**Request**: |
|
| 194 |
-```json |
|
| 195 |
-{
|
|
| 196 |
- "Name": "volume_name" |
|
| 197 |
-} |
|
| 198 |
-``` |
|
| 199 |
- |
|
| 200 |
-Get the volume info. |
|
| 201 |
- |
|
| 202 |
- |
|
| 203 |
-**Response**: |
|
| 204 |
-```json |
|
| 205 |
-{
|
|
| 206 |
- "Volume": {
|
|
| 207 |
- "Name": "volume_name", |
|
| 208 |
- "Mountpoint": "/path/to/directory/on/host", |
|
| 209 |
- "Status": {}
|
|
| 210 |
- }, |
|
| 211 |
- "Err": "" |
|
| 212 |
-} |
|
| 213 |
-``` |
|
| 214 |
- |
|
| 215 |
-Respond with a string error if an error occurred. `Mountpoint` and `Status` are |
|
| 216 |
-optional. |
|
| 217 |
- |
|
| 218 |
- |
|
| 219 |
-### /VolumeDriver.List |
|
| 220 |
- |
|
| 221 |
-**Request**: |
|
| 222 |
-```json |
|
| 223 |
-{}
|
|
| 224 |
-``` |
|
| 225 |
- |
|
| 226 |
-Get the list of volumes registered with the plugin. |
|
| 227 |
- |
|
| 228 |
-**Response**: |
|
| 229 |
-```json |
|
| 230 |
-{
|
|
| 231 |
- "Volumes": [ |
|
| 232 |
- {
|
|
| 233 |
- "Name": "volume_name", |
|
| 234 |
- "Mountpoint": "/path/to/directory/on/host" |
|
| 235 |
- } |
|
| 236 |
- ], |
|
| 237 |
- "Err": "" |
|
| 238 |
-} |
|
| 239 |
-``` |
|
| 240 |
- |
|
| 241 |
-Respond with a string error if an error occurred. `Mountpoint` is optional. |
|
| 242 |
- |
|
| 243 |
-### /VolumeDriver.Capabilities |
|
| 244 |
- |
|
| 245 |
-**Request**: |
|
| 246 |
-```json |
|
| 247 |
-{}
|
|
| 248 |
-``` |
|
| 249 |
- |
|
| 250 |
-Get the list of capabilities the driver supports. |
|
| 251 |
-The driver is not required to implement this endpoint, however in such cases |
|
| 252 |
-the default values will be taken. |
|
| 253 |
- |
|
| 254 |
-**Response**: |
|
| 255 |
-```json |
|
| 256 |
-{
|
|
| 257 |
- "Capabilities": {
|
|
| 258 |
- "Scope": "global" |
|
| 259 |
- } |
|
| 260 |
-} |
|
| 261 |
-``` |
|
| 262 |
- |
|
| 263 |
-Supported scopes are `global` and `local`. Any other value in `Scope` will be |
|
| 264 |
-ignored and assumed to be `local`. Scope allows cluster managers to handle the |
|
| 265 |
-volume differently, for instance with a scope of `global`, the cluster manager |
|
| 266 |
-knows it only needs to create the volume once instead of on every engine. More |
|
| 267 |
-capabilities may be added in the future. |