diff --git a/plugin/manager.go b/plugin/manager.go index 2bdf82e56f..750e3a5349 100644 --- a/plugin/manager.go +++ b/plugin/manager.go @@ -19,6 +19,7 @@ import ( "github.com/docker/docker/layer" "github.com/docker/docker/pkg/authorization" "github.com/docker/docker/pkg/ioutils" + "github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/pubsub" "github.com/docker/docker/pkg/system" "github.com/docker/docker/plugin/v2" @@ -155,6 +156,10 @@ func (pm *Manager) HandleExitEvent(id string) error { if restart { pm.enable(p, c, true) + } else { + if err := mount.RecursiveUnmount(filepath.Join(pm.config.Root, id)); err != nil { + return errors.Wrap(err, "error cleaning up plugin mounts") + } } return nil } diff --git a/plugin/manager_linux.go b/plugin/manager_linux.go index 1def28c2a0..a98702802f 100644 --- a/plugin/manager_linux.go +++ b/plugin/manager_linux.go @@ -187,6 +187,9 @@ func (pm *Manager) Shutdown() { shutdownPlugin(p, c, pm.executor) } } + if err := mount.RecursiveUnmount(pm.config.Root); err != nil { + logrus.WithError(err).Warn("error cleaning up plugin mounts") + } } func (pm *Manager) upgradePlugin(p *v2.Plugin, configDigest digest.Digest, blobsums []digest.Digest, tmpRootFSDir string, privileges *types.PluginPrivileges) (err error) {