Change a device path using docker plugin set
In this step, we will learn how to change the path of a device that a Docker plugin has access to using the docker plugin set
command. Some plugins might require direct access to host devices, such as storage devices or network interfaces.
As with changing other plugin settings, the plugin must be disabled before you can modify its device configurations. We will continue using the vieux/sshfs
plugin as our example, although this specific plugin doesn't typically require device access. We will demonstrate the command syntax using a hypothetical device.
First, ensure the vieux/sshfs
plugin is disabled.
docker plugin disable vieux/sshfs:latest
Verify the plugin is disabled using docker plugin ls
.
Now, let's imagine the vieux/sshfs
plugin had a requirement to access a device at /dev/sda1
. We want to change this to /dev/sdb1
. We would use the docker plugin set
command with the Devices
array.
Note: The vieux/sshfs
plugin does not actually have a Devices
configuration by default. This is a hypothetical example to demonstrate the command syntax for changing device paths. Running this command on the vieux/sshfs
plugin will likely result in an error because the Devices
field does not exist in its configuration. However, the syntax shown is correct for plugins that do have device configurations.
Assuming the plugin had a Devices
array and we wanted to change the PathOnHost
of the first device (Devices[0]
), the command would look like this:
docker plugin set vieux/sshfs:latest Devices[0].PathOnHost=/dev/sdb1
This command attempts to set the PathOnHost
field of the first device (Devices[0]
) for the vieux/sshfs:latest
plugin to /dev/sdb1
. The syntax Devices[0]
refers to the first element in the Devices
array within the plugin's settings.
Since the vieux/sshfs
plugin doesn't have a Devices
array, the command above will fail. This is expected for this specific plugin, but it illustrates the correct syntax for modifying device paths for plugins that support this configuration.
To see the actual settings of the vieux/sshfs
plugin, you can inspect it again.
docker plugin inspect vieux/sshfs:latest
You will not see a Devices
section in the output for this plugin.
Finally, re-enable the plugin.
docker plugin enable vieux/sshfs:latest
Verify that the plugin is enabled using docker plugin ls
.