Attempt to disable a plugin with references (optional)
In this optional step, you will attempt to disable a plugin that is currently in use or has resources dependent on it. This will demonstrate how Docker handles such situations.
First, let's re-enable the vieux/sshfs
plugin so we can use it.
docker plugin enable vieux/sshfs
Now, let's create a Docker volume that uses the vieux/sshfs
plugin. This will create a dependency on the plugin.
docker volume create --driver vieux/sshfs -o sshcmd=user@host:/path/to/dir -o IdentityFile=~/.ssh/id_rsa sshfs_volume
Note: This command will likely fail because you don't have a valid SSH host and key configured. This is expected and serves the purpose of creating a volume that attempts to use the plugin, thus creating a reference. You will see an error message indicating that the volume creation failed.
Now, let's try to disable the vieux/sshfs
plugin again while the volume sshfs_volume
exists, even though the volume creation failed.
docker plugin disable vieux/sshfs
You should see an error message similar to this:
Error response from daemon: plugin vieux/sshfs is in use by volume sshfs_volume
This error occurs because Docker prevents you from disabling a plugin that is currently referenced by other Docker resources, such as volumes. This is a safety mechanism to prevent unexpected behavior or data loss.
To successfully disable the plugin in this scenario, you would first need to remove the dependent resource (the volume in this case). Let's remove the volume:
docker volume rm sshfs_volume
Now, you should be able to disable the plugin:
docker plugin disable vieux/sshfs
This time, the command should succeed without an error message.
This step illustrates that Docker manages dependencies and prevents you from disabling plugins that are actively being used.