diff --git a/daemon/graphdriver/btrfs/btrfs.go b/daemon/graphdriver/btrfs/btrfs.go index 400978d8af..dfe5b549f3 100644 --- a/daemon/graphdriver/btrfs/btrfs.go +++ b/daemon/graphdriver/btrfs/btrfs.go @@ -278,7 +278,10 @@ func (d *Driver) Remove(id string) error { if err := subvolDelete(d.subvolumesDir(), id); err != nil { return err } - return os.RemoveAll(dir) + if err := os.RemoveAll(dir); err != nil && !os.IsNotExist(err) { + return err + } + return nil } // Get the requested filesystem id. diff --git a/daemon/graphdriver/overlay/overlay.go b/daemon/graphdriver/overlay/overlay.go index 67b9193005..201d5f65fa 100644 --- a/daemon/graphdriver/overlay/overlay.go +++ b/daemon/graphdriver/overlay/overlay.go @@ -322,7 +322,10 @@ func (d *Driver) dir(id string) string { // Remove cleans the directories that are created for this id. func (d *Driver) Remove(id string) error { - return os.RemoveAll(d.dir(id)) + if err := os.RemoveAll(d.dir(id)); err != nil && !os.IsNotExist(err) { + return err + } + return nil } // Get creates and mounts the required file system for the given id and returns the mount path. diff --git a/daemon/graphdriver/vfs/driver.go b/daemon/graphdriver/vfs/driver.go index ef90f19142..00d9f8eca8 100644 --- a/daemon/graphdriver/vfs/driver.go +++ b/daemon/graphdriver/vfs/driver.go @@ -104,10 +104,10 @@ func (d *Driver) dir(id string) string { // Remove deletes the content from the directory for a given id. func (d *Driver) Remove(id string) error { - if _, err := os.Stat(d.dir(id)); err != nil { + if err := os.RemoveAll(d.dir(id)); err != nil && !os.IsNotExist(err) { return err } - return os.RemoveAll(d.dir(id)) + return nil } // Get returns the directory for the given id.