When the daemon shutdown ungracefully, it will left the running
containers' rootfs still be mounted. This will cause some error
when trying to remove the containers.
Signed-off-by: Lei Jitang <leijitang@huawei.com>
| ... | ... |
@@ -14,7 +14,7 @@ import ( |
| 14 | 14 |
|
| 15 | 15 |
// cleanupMounts umounts shm/mqueue mounts for old containers |
| 16 | 16 |
func (daemon *Daemon) cleanupMounts() error {
|
| 17 |
- logrus.Debugf("Cleaning up old shm/mqueue mounts: start.")
|
|
| 17 |
+ logrus.Debugf("Cleaning up old container shm/mqueue/rootfs mounts: start.")
|
|
| 18 | 18 |
f, err := os.Open("/proc/self/mountinfo")
|
| 19 | 19 |
if err != nil {
|
| 20 | 20 |
return err |
| ... | ... |
@@ -33,11 +33,11 @@ func (daemon *Daemon) cleanupMountsFromReader(reader io.Reader, unmount func(tar |
| 33 | 33 |
for sc.Scan() {
|
| 34 | 34 |
line := sc.Text() |
| 35 | 35 |
fields := strings.Fields(line) |
| 36 |
- if strings.HasPrefix(fields[4], daemon.repository) {
|
|
| 37 |
- logrus.Debugf("Mount base: %v, repository %s", fields[4], daemon.repository)
|
|
| 36 |
+ if strings.HasPrefix(fields[4], daemon.root) {
|
|
| 37 |
+ logrus.Debugf("Mount base: %v", fields[4])
|
|
| 38 | 38 |
mnt := fields[4] |
| 39 | 39 |
mountBase := filepath.Base(mnt) |
| 40 |
- if mountBase == "mqueue" || mountBase == "shm" {
|
|
| 40 |
+ if mountBase == "mqueue" || mountBase == "shm" || mountBase == "merged" {
|
|
| 41 | 41 |
logrus.Debugf("Unmounting %v", mnt)
|
| 42 | 42 |
if err := unmount(mnt); err != nil {
|
| 43 | 43 |
logrus.Error(err) |
| ... | ... |
@@ -55,6 +55,6 @@ func (daemon *Daemon) cleanupMountsFromReader(reader io.Reader, unmount func(tar |
| 55 | 55 |
return fmt.Errorf("Error cleaningup mounts:\n%v", strings.Join(errors, "\n"))
|
| 56 | 56 |
} |
| 57 | 57 |
|
| 58 |
- logrus.Debugf("Cleaning up old shm/mqueue mounts: done.")
|
|
| 58 |
+ logrus.Debugf("Cleaning up old container shm/mqueue/rootfs mounts: done.")
|
|
| 59 | 59 |
return nil |
| 60 | 60 |
} |