Skip to content

Commit

Permalink
Merge pull request #2196 from HusterWan/zr/umount-rootfs
Browse files Browse the repository at this point in the history
bugfix: umount rootfs when delete a container
  • Loading branch information
allencloud authored Sep 4, 2018
2 parents 14c94cf + 716caec commit ff5d11f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions daemon/mgr/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -1061,12 +1061,15 @@ func (mgr *ContainerManager) Remove(ctx context.Context, name string, options *t
}

// if creating the container by specify rootfs,
// there is no snapshot for this container.
if !c.RootFSProvided {
// remove snapshot
if err := mgr.Client.RemoveSnapshot(ctx, c.ID); err != nil {
logrus.Errorf("failed to remove snapshot of container %s: %v", c.ID, err)
// we should umount the rootfs when delete the container.
if c.RootFSProvided {
if err := mount.Unmount(c.BaseFS, 0); err != nil {
logrus.Errorf("failed to umount rootfs when remove the container %s: %v", c.ID, err)
}
} else if err := mgr.Client.RemoveSnapshot(ctx, c.ID); err != nil {
// if the container is created by normal method, remove the
// snapshot when delete it.
logrus.Errorf("failed to remove snapshot of container %s: %v", c.ID, err)
}

// When removing a container, we have set up such rule for object removing sequences:
Expand Down

0 comments on commit ff5d11f

Please sign in to comment.