Add diff service implementation

Add snapshot subcommand to ctr for creating diffs of RW layers.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan
2017-05-12 14:58:01 -07:00
parent 47718b0930
commit 3ae69c43d8
10 changed files with 237 additions and 20 deletions

View File

@@ -54,6 +54,10 @@ var runCommand = cli.Command{
Name: "net-host",
Usage: "enable host networking for the container",
},
cli.BoolFlag{
Name: "keep",
Usage: "keep container after running",
},
},
Action: func(context *cli.Context) error {
var (
@@ -110,7 +114,11 @@ var runCommand = cli.Command{
return err
}
mounts, err = snapshotter.Prepare(ctx, id, identity.ChainID(diffIDs).String())
if context.Bool("readonly") {
mounts, err = snapshotter.View(ctx, id, identity.ChainID(diffIDs).String())
} else {
mounts, err = snapshotter.Prepare(ctx, id, identity.ChainID(diffIDs).String())
}
if err != nil {
if !snapshot.IsExist(err) {
return err
@@ -192,10 +200,12 @@ var runCommand = cli.Command{
if err != nil {
return err
}
if _, err := containers.Delete(ctx, &execution.DeleteRequest{
ID: response.ID,
}); err != nil {
return err
if !context.Bool("keep") {
if _, err := containers.Delete(ctx, &execution.DeleteRequest{
ID: response.ID,
}); err != nil {
return err
}
}
if status != 0 {
return cli.NewExitError("", int(status))