зеркало из https://github.com/microsoft/docker.git
docker: Make sure to umount the container if it's still mounted at
destruction
This commit is contained in:
Родитель
174f25909c
Коммит
fb40a78804
10
docker.go
10
docker.go
|
@ -67,10 +67,14 @@ func (docker *Docker) Destroy(container *Container) error {
|
||||||
if err := container.Stop(); err != nil {
|
if err := container.Stop(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := os.RemoveAll(container.Root); err != nil {
|
if container.Filesystem.IsMounted() {
|
||||||
return err
|
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)
|
docker.containers.Remove(element)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,8 @@ func (fs *Filesystem) Umount() error {
|
||||||
if fs.IsMounted() {
|
if fs.IsMounted() {
|
||||||
return fmt.Errorf("Umount: Filesystem still mounted after calling umount(%v)", fs.RootFS)
|
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++ {
|
for retries := 0; retries < 1000; retries++ {
|
||||||
err := os.Remove(fs.RootFS)
|
err := os.Remove(fs.RootFS)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче