mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
devmapper: Remove directory when removing devicemapper device
We're currently leaving around lots of empty directories in /var/lib/docker/devicemapper/mnt/ for removed images and containers. Fix this by removing the directory when the device is removed. Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
This commit is contained in:
parent
8228e50581
commit
2343fe4453
1 changed files with 11 additions and 1 deletions
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/dotcloud/docker/graphdriver"
|
"github.com/dotcloud/docker/graphdriver"
|
||||||
"github.com/dotcloud/docker/utils"
|
"github.com/dotcloud/docker/utils"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -94,7 +95,16 @@ func (d *Driver) Remove(id string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// This assumes the device has been properly Get/Put:ed and thus is unmounted
|
// This assumes the device has been properly Get/Put:ed and thus is unmounted
|
||||||
return d.DeviceSet.DeleteDevice(id)
|
if err := d.DeviceSet.DeleteDevice(id); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
mp := path.Join(d.home, "mnt", id)
|
||||||
|
if err := os.RemoveAll(mp); err != nil && !os.IsNotExist(err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Get(id string) (string, error) {
|
func (d *Driver) Get(id string) (string, error) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue