1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

docker: Make sure to umount the container if it's still mounted at

destruction
This commit is contained in:
Andrea Luzzardi 2013-01-28 11:58:59 -08:00
parent 174f25909c
commit fb40a78804
2 changed files with 9 additions and 3 deletions

View file

@ -67,10 +67,14 @@ func (docker *Docker) Destroy(container *Container) error {
if err := container.Stop(); err != nil {
return err
}
if err := os.RemoveAll(container.Root); err != nil {
return err
if container.Filesystem.IsMounted() {
if err := container.Filesystem.Umount(); err != nil {
log.Printf("Unable to umount container %v: %v", container.Id, err)
}
}
if err := os.RemoveAll(container.Root); err != nil {
log.Printf("Unable to remove filesystem for %v: %v", container.Id, err)
}
docker.containers.Remove(element)
return nil
}

View file

@ -58,6 +58,8 @@ func (fs *Filesystem) Umount() error {
if fs.IsMounted() {
return fmt.Errorf("Umount: Filesystem still mounted after calling umount(%v)", fs.RootFS)
}
// Even though we just unmounted the filesystem, AUFS will prevent deleting the mntpoint
// for some time. We'll just keep retrying until it succeeds.
for retries := 0; retries < 1000; retries++ {
err := os.Remove(fs.RootFS)
if err == nil {