Delete rootfs when container is deleted

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan
2017-05-15 17:38:12 -07:00
parent 3ae69c43d8
commit 4304da2b58
2 changed files with 26 additions and 2 deletions

View File

@@ -127,6 +127,14 @@ var runCommand = cli.Command{
if err != nil {
return err
}
} else {
defer func() {
if id != "" {
if err := snapshotter.Remove(ctx, id); err != nil {
logrus.WithError(err).Errorf("failed to remove snapshot %q", id)
}
}
}()
}
ic, err := image.Config(ctx, content)
@@ -206,6 +214,9 @@ var runCommand = cli.Command{
}); err != nil {
return err
}
} else {
// Don't remove snapshot
id = ""
}
if status != 0 {
return cli.NewExitError("", int(status))