How to use docker plugin install command to install and manage plugins

DockerDockerBeginner
Practice Now

Introduction

In this lab, you will learn how to install and manage Docker plugins using the docker plugin install command. You will explore different installation scenarios, including installing a plugin with default settings, installing a plugin and configuring it with specific parameters, and installing a plugin without immediately enabling it.

Through hands-on examples, you will gain practical experience in extending Docker's capabilities by integrating external services for storage and other functionalities. Finally, you will learn how to verify the successful installation of your plugins.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL docker(("Docker")) -.-> docker/ContainerOperationsGroup(["Container Operations"]) docker(("Docker")) -.-> docker/VolumeOperationsGroup(["Volume Operations"]) docker(("Docker")) -.-> docker/SystemManagementGroup(["System Management"]) docker(("Docker")) -.-> docker/NetworkOperationsGroup(["Network Operations"]) docker/ContainerOperationsGroup -.-> docker/ls("List Containers") docker/ContainerOperationsGroup -.-> docker/inspect("Inspect Container") docker/VolumeOperationsGroup -.-> docker/volume("Manage Volumes") docker/SystemManagementGroup -.-> docker/system("Manage Docker") docker/NetworkOperationsGroup -.-> docker/network("Manage Networks") subgraph Lab Skills docker/ls -.-> lab-555191{{"How to use docker plugin install command to install and manage plugins"}} docker/inspect -.-> lab-555191{{"How to use docker plugin install command to install and manage plugins"}} docker/volume -.-> lab-555191{{"How to use docker plugin install command to install and manage plugins"}} docker/system -.-> lab-555191{{"How to use docker plugin install command to install and manage plugins"}} docker/network -.-> lab-555191{{"How to use docker plugin install command to install and manage plugins"}} end

Install a plugin with default settings

In this step, you will learn how to install a Docker plugin with its default settings. Docker plugins extend the functionality of Docker, allowing you to integrate with external systems for storage, networking, and more.

To install a plugin, you use the docker plugin install command followed by the plugin name. Docker will pull the plugin from Docker Hub by default.

Let's install the rexray/s3fs plugin, which provides S3-backed storage for Docker volumes.

docker plugin install rexray/s3fs

When you run this command, Docker will download the plugin and ask for confirmation to grant it necessary permissions. Type y and press Enter to proceed.

Plugin "rexray/s3fs" is requesting the following permissions:
 - network: [host]
 - mount: [/dev/fuse]
 - allow-vulnerable-api: true
 - allow-host-access: true
 - allow-device: [/dev/fuse]
 - allow-cap: [sys_admin]
Do you grant the plugin "rexray/s3fs" these permissions? [y/N] y

After confirming, Docker will install and enable the plugin. You should see output indicating that the plugin has been installed and enabled.

rexray/s3fs:latest

This output confirms that the rexray/s3fs plugin has been successfully installed and is now enabled, ready to be used for creating S3-backed volumes.

Install a plugin and set configuration parameters

In this step, you will learn how to install a Docker plugin and configure it with specific parameters during installation. Some plugins require configuration settings, such as API keys, endpoints, or other service-specific details, to function correctly.

You can pass configuration parameters to the docker plugin install command using the format plugin_name parameter_name=parameter_value.

Let's install the vieux/sshfs plugin, which allows you to use SSHFS for Docker volumes. This plugin requires specifying the SSH user and host.

docker plugin install vieux/sshfs SSH_USER=labex SSH_HOST=localhost

Similar to the previous step, Docker will download the plugin and ask for permissions. Type y and press Enter to grant the permissions.

Plugin "vieux/sshfs" is requesting the following permissions:
 - network: [host]
 - mount: [/dev/fuse]
 - allow-vulnerable-api: true
 - allow-host-access: true
 - allow-device: [/dev/fuse]
 - allow-cap: [sys_admin]
Do you grant the plugin "vieux/sshfs" these permissions? [y/N] y

After confirming, the plugin will be installed and enabled with the specified configuration parameters.

vieux/sshfs:latest

This output confirms that the vieux/sshfs plugin has been installed and enabled with the SSH_USER set to labex and SSH_HOST set to localhost. These parameters will be used by the plugin when creating volumes.

Install a plugin without enabling it

In this step, you will learn how to install a Docker plugin without immediately enabling it. This can be useful if you want to install a plugin but don't want it to be active until you are ready to use it, or if you need to perform additional configuration steps before enabling.

To install a plugin without enabling it, you use the --disable flag with the docker plugin install command.

Let's install the containernetworking/cni plugin, which provides CNI network capabilities, but keep it disabled for now.

docker plugin install --disable containernetworking/cni

Docker will download the plugin and ask for permissions. Type y and press Enter to grant the permissions.

Plugin "containernetworking/cni" is requesting the following permissions:
 - network: [host]
 - mount: [/dev/fuse]
 - allow-vulnerable-api: true
 - allow-host-access: true
 - allow-device: [/dev/fuse]
 - allow-cap: [sys_admin]
Do you grant the plugin "containernetworking/cni" these permissions? [y/N] y

After confirming, the plugin will be installed but will remain in a disabled state.

containernetworking/cni:latest

This output confirms that the containernetworking/cni plugin has been successfully installed. In the next step, we will verify its status.

Verify the installed plugin

In this step, you will learn how to verify the status of installed Docker plugins. You can check which plugins are installed, their version, and whether they are enabled or disabled.

To list all installed plugins, you use the docker plugin ls command.

docker plugin ls

This command will display a table with information about each installed plugin, including its ID, Name, Description, Enabled status, and Version.

You should see the three plugins we installed in the previous steps: rexray/s3fs, vieux/sshfs, and containernetworking/cni.

ID                  NAME                       DESCRIPTION                                            ENABLED             VERSION
a1b2c3d4e5f6        rexray/s3fs:latest         REX-Ray S3FS Plugin                                    true                latest
g7h8i9j0k1l2        vieux/sshfs:latest         The `sshfs` plugin for Docker.                         true                latest
m3n4o5p6q7r8        containernetworking/cni:latest CNI network plugin for Docker                        false               latest

Notice that rexray/s3fs and vieux/sshfs are listed as ENABLED (true), while containernetworking/cni is listed as ENABLED (false), as we installed it with the --disable flag.

You can also inspect a specific plugin for more detailed information using the docker plugin inspect command followed by the plugin name or ID.

Let's inspect the containernetworking/cni plugin:

docker plugin inspect containernetworking/cni

This command will output a detailed JSON object containing all the configuration and status information for the plugin. You can examine this output to confirm the plugin's settings and state. Look for the "Enabled": false line in the output to confirm it is disabled.

[
  {
    "Id": "m3n4o5p6q7r8",
    "Name": "containernetworking/cni:latest",
    "Enabled": false,
    "Settings": {
      "Args": [],
      "Env": [],
      "Devices": [],
      "Mounts": []
    },
    "PluginReference": "docker.io/containernetworking/cni:latest",
    "Config": {
      "DockerVersion": "20.10.21",
      "Description": "CNI network plugin for Docker",
      "Documentation": "https://github.com/containernetworking/cni",
      "Interface": {
        "Types": ["docker.networkdriver/1.0"],
        "Socket": "cni.sock"
      },
      "Entrypoint": ["/docker-cni-plugin"],
      "PropagatedMount": "/opt/cni",
      "WorkDir": "",
      "User": {},
      "Args": {
        "Name": "",
        "Description": ""
      },
      "Linux": {
        "Capabilities": ["CAP_SYS_ADMIN"],
        "AllowAllDevices": false,
        "Devices": [
          {
            "Name": "fuse",
            "Path": "/dev/fuse"
          }
        ]
      },
      "Rootfs": {
        "Type": "tar",
        "DiffIds": ["sha256:..."]
      }
    }
  }
]

This step concludes the process of installing and verifying Docker plugins. You have learned how to install plugins with default settings, with specific configuration parameters, and how to install them without enabling them immediately. You also know how to list and inspect installed plugins to verify their status.

Summary

In this lab, you learned how to install and manage Docker plugins using the docker plugin install command. You practiced installing a plugin with default settings, which involves simply specifying the plugin name and confirming the requested permissions.

Furthermore, you explored how to install a plugin while setting specific configuration parameters during the installation process, demonstrating how to customize plugin behavior from the outset. Finally, you learned how to verify the successful installation of a plugin.