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)
| ... | ... |
@@ -7,6 +7,7 @@ import ( |
| 7 | 7 |
"github.com/dotcloud/docker/graphdriver" |
| 8 | 8 |
"github.com/dotcloud/docker/utils" |
| 9 | 9 |
"io/ioutil" |
| 10 |
+ "os" |
|
| 10 | 11 |
"path" |
| 11 | 12 |
) |
| 12 | 13 |
|
| ... | ... |
@@ -94,7 +95,16 @@ func (d *Driver) Remove(id string) error {
|
| 94 | 94 |
return err |
| 95 | 95 |
} |
| 96 | 96 |
// This assumes the device has been properly Get/Put:ed and thus is unmounted |
| 97 |
- return d.DeviceSet.DeleteDevice(id) |
|
| 97 |
+ if err := d.DeviceSet.DeleteDevice(id); err != nil {
|
|
| 98 |
+ return err |
|
| 99 |
+ } |
|
| 100 |
+ |
|
| 101 |
+ mp := path.Join(d.home, "mnt", id) |
|
| 102 |
+ if err := os.RemoveAll(mp); err != nil && !os.IsNotExist(err) {
|
|
| 103 |
+ return err |
|
| 104 |
+ } |
|
| 105 |
+ |
|
| 106 |
+ return nil |
|
| 98 | 107 |
} |
| 99 | 108 |
|
| 100 | 109 |
func (d *Driver) Get(id string) (string, error) {
|