How to manage Docker Engine plugins – CloudSavvy IT

0

Docker Engine supports a plug-in system that allows you to add additional functionality to the container runtime environment. Plugins for new storage drivers, networking stacks, and logging systems are all available for free.

Modern versions of Docker Engine include everything you need to manage plugins in the CLI. We focus on this “managed” plugin system in this guide. You must manually install and maintain the plugins that use the legacy plugin system.

All about plugins

Plugins extend Docker Engine with new features that are too specific to ship with the general installation. Normally, you don’t directly interact with the plugins. Once a plugin is installed, you can reference the resources it provides when running existing Docker commands.

There are three main types of plugins:

  • Registration – These plugins add new logging drivers, allowing you to store logs in locations outside of Docker Engine and your host machine.
  • Network – Networking plug-ins can add support for new network types and related functionality.
  • Volume – Storage plugins bring additional file systems and volume drivers to Docker, giving you more options for persistent data.

Plugins with features that fall outside of these main areas are also available. The plugins are created by community providers; you can write your own using the audience Plugins API and Go SDK.

The plugins are distributed via Docker Hub. You can find the available plugins by going to the Explore page and selecting the Plugins tab at the top. More than 600 plugins are currently available.

If you are writing your own plugin, you can submit it to Docker Hub with the docker plugin push order. It works the same as pushing an image into the public registry. You have to run docker plugin create first to convert your plugin’s manifest and filesystem into a ready-to-submit package. You can get more information about creating plugins in the Docker documents.

Install a plugin

The plugins are installed with the docker plugin install order. This accepts the name of a Docker Hub plugin as an argument:

docker plugin install store/example/example-plugin:version

Plugin references look like image references that start with store/. The same markup principles apply when specifying which plugin version to install. Unlike images, you cannot omit the version to automatically extract the latest label.

You can find a plugin’s version number and copy an out-of-the-box installation command by clicking the “Setup Instructions” button on its Docker Hub page. Free plugins will allow you to switch to a new screen with the normal copy-paste box at the top right. Run the command in your terminal to start the plugin installation.

Plugins typically request access to host privileges so that they can provide their functionality. For example, a network plugin will need to have access to Docker host network so that it can connect new resources. Confirm the permission prompt by typing y and press Enter to complete the installation. You can ignore the prompt by adding the --grant-all-permissions flag to your install order; this is ideal for non-interactive installations but risks granting unintentional permissions if a plugin is updated with new features.

The plugins are automatically activated after installation. Activating a plugin allows the execution of pre-installation scripts. Use the --disable flag to set a plugin to the disabled state by default, leaving it inert until it is manually enabled later.

Viewing plug-in details

Once installed, your plugin will be displayed during execution docker plugin ls:

docker plugin ls

More detailed information on a single plugin can be obtained from the docker inspect order. This accepts a plug-in ID or tag and displays a detailed JSON that describes the plug-in manifest:

docker inspect eccffc

Offline installation

The Docker CLI does not have a built-in way to install plugins offline. However, you can add plugins to an empty Docker installation by installing them first on a network client and then copying the plug-in files to the offline system.

You will find the plugins installed in the /var/lib/docker/plugins directory on your host. Each plugin gets its own subdirectory named with its ID. These identifiers are visible in the output of the docker plugin ls order.

Activation and deactivation of plugins

Plugins can be enabled or disabled. You will see the current status in the last column of the ls to go out. A disabled plugin will not be loaded, so it will act as if it is not installed.

Use the docker plugin enable and docker plugin disable commands to change the status of a plugin. Provide the ID of one of your installed plugins as the only argument to the command:

docker plugin enable eccffc

You may not be able to deactivate a plugin if it is actively in use by your Docker Engine configuration or one of your containers. Addition of -f flag will force the plug-in to be disabled but should be used sparingly as you risk unintentional container exits.

The plugins are uninstalled with the docker plugin rm order. Provide the ID or name of a plugin to completely remove it from Docker. rm has the same behaviors as disable when managing actively used plugins and forced deletions afterwards.

Modifying plugin settings

Docker’s plugin system includes a built-in mechanism for plugin authors to expose customizable settings. As a user, you can change these settings via the docker plugin set order:

docker plugin set example-plugin setting-key=new-value

To replace example-plugin with the ID or name of the plugin you are targeting. The value of the plugin setting-key the setting will be updated to new-value.

The available parameters naturally vary from one plugin to another. They must be documented in the plugin description on Docker Hub. The Docker CLI doesn’t have a built-in command to display all the settings available for a plugin, but they do show up in docker plugin inspect to go out. Look for the Settings field in the JSON representation of a plugin; it will contain objects with Name and Settable fields for options that you can change via the CLI.

Update your plugins

The plugins are updated with the docker plugin update order. Like other commands, it takes a plugin id or tag as an argument.

Upgrading a plugin will download and install the latest version available on Docker Hub. If you are already using the latest version, the command will reinstall the current version. You will be prompted to grant the plugin any new privileges it needs. the --grant-all-permissions flag is accepted to ignore the prompt in environments where interactive input is not possible.

There is no way to update all the plugins on your system with one command. It’s best to subscribe to release announcements from your plugin vendors and then apply updates to your installation as they become available. This will ensure that your plugins remain secure and supported.

Summary

The Docker plugin ecosystem allows you to add additional functionality to Docker Engine. The plugins reside on Docker Hub and can be installed from your terminal. The CLI has a built-in plugin updater, but it only works with one plugin at a time, not your entire catalog.

Now that you know how to use and manage plugins, you can start browsing Docker Hub for options to improve your workflow. Elastic logging plugin streams Docker container logs to an Elastic stack cluster, vSphere for Docker allows you to use VMWare vSphere storage for your persistent volumes, and Weaving net brings encrypted multicast networking to Docker. If you don’t see what you need, use the Plugin API to try to write your own solution that you can publish to the whole community through the Hub.


Source link

Share.

Comments are closed.