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:
parent
174f25909c
commit
fb40a78804
2 changed files with 9 additions and 3 deletions
10
docker.go
10
docker.go
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue