Working with Docker Plugins
1. Installing Volume Plugins
| Plugin Type | Description | Installation Method | Notes |
|---|---|---|---|
| volume | Enables Docker to use external storage systems as volumes | docker plugin install |
Must be installed on the host machine where Docker runs |
Note: The
--alias flag allows you to give a custom name to the plugin for easier reference in volume creation.
2. Listing Plugins
| Command | Description | Options |
|---|---|---|
| docker plugin ls | List all installed plugins | --format, --filter |
| docker plugin ls --format json | Output in JSON format | |
| docker plugin ls --filter name=plugin-name | Filter plugins by name |
3. Inspecting Plugins
| Command | Description | Example |
|---|---|---|
| docker plugin ls | List all installed plugins | docker plugin ls |
| docker plugin inspect <plugin-name> | Inspect a specific plugin's configuration and details | docker plugin inspect example/plugin |
Note: The inspect command returns a JSON object containing plugin metadata, settings, and capabilities.
4. Enabling Plugins
| Plugin | Enable Command | Description |
|---|---|---|
| docker-volume-local | docker plugin enable local |
Enables the local volume driver plugin |
| docker-volume-aws | docker plugin enable amazon/ec2 |
Enables the AWS EBS volume driver plugin |
| docker-network-overlay | docker plugin enable overlay |
Enables the overlay network driver plugin |
Note: Plugins must be installed before they can be enabled.
5. Disabling Plugins
| Plugin | Status | Command | Notes |
|---|---|---|---|
| example-plugin | DEPRECATED | docker plugin disable example-plugin |
Plugin is deprecated as of Docker 25.0 |
| volume-plugin | NEW | docker plugin disable volume-plugin |
Available in Docker 26.0+ |
Note: Disabling a plugin does not remove it from the system. It can be re-enabled later using
docker plugin enable.
6. Configuring Plugin Options
| Option | Description | Default Value | Notes |
|---|---|---|---|
| --config | Path to the plugin configuration file | null |
Used to specify a custom config file for plugin settings |
| --env | Set environment variables for the plugin | null |
Can be used to pass runtime configuration to the plugin |
| --volume | Mount a volume into the plugin container | null |
Allows access to host filesystem from within the plugin |
Example: Setting Plugin Configuration
docker plugin install --config /etc/plugin-config.json my-plugin
Note: Plugin configuration options are defined by the plugin developer and may vary depending on the plugin type.
7. Using Network Plugins
| Plugin | Description | Usage | Notes |
|---|---|---|---|
| bridge | Default network driver for containers | docker run --network bridge <image> |
Isolated network namespace per container |
| host | Shares host network namespace | docker run --network host <image> |
Bypasses Docker networking |
| none | No network access for container | docker run --network none <image> |
Container has no network interface |
| overlay | Connects multiple Docker daemons | docker network create --driver overlay <name> |
Used in swarm mode for multi-host networks |
Example: Creating an Overlay Network
docker network create --driver overlay --subnet=10.0.9.0/24 my-overlay-network
Note: Overlay networks require a key-value store like Consul, Etcd, or ZooKeeper to manage the network configuration across multiple Docker daemons.
Example: Attaching a Service to an Overlay Network
docker service create --name my-service --network my-overlay-network nginx
Warning: Ensure that the key-value store is properly configured before creating overlay networks in swarm mode.
8. Using Storage Plugins
| Property | Value | Description |
|---|---|---|
| driver | local |
Default storage driver for Docker volumes |
| driver | overlay2 |
Recommended for production environments |
| driver | btrfs |
For systems with Btrfs filesystem support |
| driver | zfs |
For systems with ZFS filesystem support |
Note: The storage driver must be set at Docker daemon startup and cannot be changed without reconfiguring the daemon.
Warning: Changing storage drivers after data has been written can lead to data loss or corruption.
| Driver | Supported OS | Features | Notes |
|---|---|---|---|
local |
All | Basic volume management | Simple and lightweight, not suitable for multi-host setups |
overlay2 |
Linux | Multi-layered, efficient | Default in modern Docker versions |
btrfs |
Linux | Snapshot support, compression | Requires Btrfs filesystem |
zfs |
Linux, FreeBSD | Snapshotting, compression, encryption | Requires ZFS filesystem |
9. Upgrading Plugins
| Command | Description | Notes |
|---|---|---|
| docker plugin upgrade <plugin> | Upgrades a Docker plugin to the latest version | Requires plugin to be disabled first |
| docker plugin upgrade --grant-all-permissions <plugin> | Upgrades plugin and grants all permissions | Useful for plugins requiring extensive access |
Example: Upgrading a Plugin
# Disable plugin before upgrade
docker plugin disable example/plugin:latest
# Upgrade plugin to latest version
docker plugin upgrade example/plugin:latest
# Re-enable plugin after upgrade
docker plugin enable example/plugin:latest
Note: Plugin upgrades may require disabling and re-enabling the plugin to take effect.
Warning: Ensure compatibility with current Docker version before upgrading plugins.
10. Creating Custom Plugins
Creating custom Docker plugins allows you to extend Docker's functionality with your own logic and features. Plugins are built as separate executables that communicate with the Docker daemon via a defined API.
| Component | Description | Details |
|---|---|---|
| Plugin Structure | Directory layout of a plugin | |
| plugin.json | Plugin manifest file | Defines plugin metadata, capabilities, and configuration. |
Example: plugin.json
{
"name": "my-plugin",
"description": "A custom Docker plugin",
"version": "1.0.0",
"capabilities": [
"volume"
],
"apiVersion": "1.0"
}
Note: The plugin binary must be executable and placed in the same directory as
plugin.json.
Workflow: Creating a Custom Plugin
- Create a directory for your plugin.
- Write the plugin binary in any language that supports command-line interfaces (e.g., Go, Python).
- Define the plugin metadata in
plugin.json. - Ensure the binary is executable and placed in the plugin directory.
- Install the plugin using
docker plugin install.
Plugin Types
- Volume Plugins: Extend storage capabilities.
- Network Plugins: Manage network connectivity and routing.
- Log Plugins: Handle logging output from containers.
11. Managing Plugin Permissions
| Permission | Description | Default Scope | Notes |
|---|---|---|---|
| docker plugin install --grant-all-permissions | Installs a plugin and grants all permissions | All permissions | Use with caution as it grants full access to the Docker daemon |
| docker plugin install --grant-permission | Installs a plugin and grants specific permissions | Selected permissions | Allows fine-grained control over plugin access |
| docker plugin ls --filter capability= | Lists plugins with specific capabilities | Filtered by capability | Useful for auditing plugin permissions |
Example: Installing a Plugin with Specific Permissions
docker plugin install --grant-permission network --grant-permission volume example/plugin
Note: Plugin permissions are managed at the Docker daemon level and can be configured via the
daemon.json file.
Warning: Granting all permissions to a plugin can pose security risks. Always review the plugin's capabilities before granting permissions.
12. Removing Plugins
| Command | Description | Notes |
|---|---|---|
| docker plugin rm <plugin-name> | Remove a plugin | Plugin must be disabled before removal |
| docker plugin rm <plugin-name> --force | Force remove a plugin | Removes plugin even if it's enabled |
Note: Ensure the plugin is not in use before removal to avoid unexpected behavior.