diff --git a/drivers/overlay/check.go b/drivers/overlay/check.go index d8139f6566..db8d13353e 100644 --- a/drivers/overlay/check.go +++ b/drivers/overlay/check.go @@ -263,7 +263,9 @@ func supportsIdmappedLowerLayers(home string) (bool, error) { if err := idmap.CreateIDMappedMount(lowerDir, lowerMappedDir, int(pid)); err != nil { return false, fmt.Errorf("create mapped mount: %w", err) } - defer unix.Unmount(lowerMappedDir, unix.MNT_DETACH) + defer func() { + _ = unix.Unmount(lowerMappedDir, unix.MNT_DETACH) + }() opts := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", lowerMappedDir, upperDir, workDir) flags := uintptr(0) diff --git a/drivers/overlay/overlay.go b/drivers/overlay/overlay.go index 0585228981..c30b51c7af 100644 --- a/drivers/overlay/overlay.go +++ b/drivers/overlay/overlay.go @@ -1553,7 +1553,9 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO composefsMounts := []string{} defer func() { for _, m := range composefsMounts { - defer unix.Unmount(m, unix.MNT_DETACH) + defer func(m string) { + _ = unix.Unmount(m, unix.MNT_DETACH) + }(m) } }() @@ -1657,7 +1659,9 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO skipIDMappingLayers[composefsMount] = composefsMount // overlay takes a reference on the mount, so it is safe to unmount // the mapped idmounts as soon as the final overlay file system is mounted. - defer unix.Unmount(composefsMount, unix.MNT_DETACH) + defer func() { + _ = unix.Unmount(composefsMount, unix.MNT_DETACH) + }() } absLowers = append(absLowers, composefsMount) continue @@ -1764,7 +1768,9 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO // overlay takes a reference on the mount, so it is safe to unmount // the mapped idmounts as soon as the final overlay file system is mounted. - defer unix.Unmount(root, unix.MNT_DETACH) + defer func() { + _ = unix.Unmount(root, unix.MNT_DETACH) + }() } // relative path to the layer through the id mapped mount