How to use docker plugin ls command to list plugins

DockerDockerBeginner
Practice Now

Introduction

In this lab, you will learn how to use the docker plugin ls command to manage and view Docker plugins. We will cover the fundamental steps of listing all installed plugins, filtering the list based on their enabled status, and further refining the output by filtering based on plugin capabilities. Finally, you will learn how to format the plugin output using a Go template for customized views. This hands-on experience will equip you with the skills to effectively inspect and manage Docker plugins in your environment.


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/VolumeOperationsGroup -.-> docker/volume("Manage Volumes") docker/SystemManagementGroup -.-> docker/system("Manage Docker") docker/NetworkOperationsGroup -.-> docker/network("Manage Networks") subgraph Lab Skills docker/ls -.-> lab-555192{{"How to use docker plugin ls command to list plugins"}} docker/volume -.-> lab-555192{{"How to use docker plugin ls command to list plugins"}} docker/system -.-> lab-555192{{"How to use docker plugin ls command to list plugins"}} docker/network -.-> lab-555192{{"How to use docker plugin ls command to list plugins"}} end

List all installed plugins

In this step, we will learn how to list all installed Docker plugins on your system. Docker plugins extend the functionality of Docker, providing features like volume management, networking, and logging.

To list the installed plugins, you can use the docker plugin ls command. This command will display a table with information about each installed plugin, including its ID, name, description, and enabled status.

Let's execute the command to see the installed plugins:

docker plugin ls

You should see output similar to this (the exact output may vary depending on your environment):

ID    NAME    DESCRIPTION    ENABLED

In a default LabEx environment, there might not be any plugins installed by default. The output above shows an empty list, indicating no plugins are currently installed. If you had plugins installed, they would be listed here.

Filter plugins by enabled status

In this step, we will learn how to filter the list of Docker plugins based on their enabled status. This is useful when you only want to see plugins that are currently active or inactive.

You can use the --filter flag with the docker plugin ls command to filter the output. The filter key for enabled status is enabled. You can set the value to true to see only enabled plugins or false to see only disabled plugins.

Since there are no plugins installed by default in this environment, filtering by enabled status will still result in an empty list. However, let's demonstrate the command structure.

To list only enabled plugins, you would use:

docker plugin ls --filter enabled=true

The output will be:

ID    NAME    DESCRIPTION    ENABLED

To list only disabled plugins, you would use:

docker plugin ls --filter enabled=false

The output will also be:

ID    NAME    DESCRIPTION    ENABLED

Although the output is empty in this environment, understanding how to use the --filter enabled= flag is important for managing plugins in environments where they are installed.

Filter plugins by capability

In this step, we will explore how to filter Docker plugins based on their capabilities. Plugins can have different capabilities, such as volumedriver for volume management, networkdriver for networking, or logdriver for logging. Filtering by capability allows you to find plugins that provide specific functionalities.

Similar to filtering by enabled status, we use the --filter flag with the docker plugin ls command. The filter key for capability is capability. You can specify the desired capability as the value.

Since there are no plugins installed in this environment, filtering by capability will also result in an empty list. However, let's look at the command structure.

To list plugins with the volumedriver capability, you would use:

docker plugin ls --filter capability=volumedriver

The output will be:

ID    NAME    DESCRIPTION    ENABLED

To list plugins with the networkdriver capability, you would use:

docker plugin ls --filter capability=networkdriver

The output will also be:

ID    NAME    DESCRIPTION    ENABLED

Understanding how to filter by capability is useful for identifying plugins that can fulfill specific requirements for your Docker environment.

Format plugin output using a template

In this step, we will learn how to format the output of the docker plugin ls command using a Go template. This allows you to customize the output to display only the information you need and in a specific format.

The --format flag is used to specify the template. You can use placeholders like .ID, .Name, .Description, and .Enabled to access the different fields of each plugin.

Let's try formatting the output to show only the plugin name and its enabled status, separated by a colon.

docker plugin ls --format "{{.Name}}: {{.Enabled}}"

Since there are no plugins installed, the output will be empty. However, if you had plugins, the output would look something like this:

my-plugin: true
another-plugin: false

You can create more complex templates to include other information or format the output differently. For example, to display the ID and description:

docker plugin ls --format "ID: {{.ID}}, Description: {{.Description}}"

Again, the output will be empty in this environment.

Using the --format flag is a powerful way to tailor the output of Docker commands to your specific needs, making it easier to parse and process the information.

Summary

In this lab, we learned how to use the docker plugin ls command to manage Docker plugins. We started by listing all installed plugins, understanding that the default environment might not have any pre-installed. We then explored how to filter the plugin list based on their enabled status using the --filter enabled= flag, demonstrating how to view only enabled or disabled plugins, even in an environment without installed plugins.