@@ -3,6 +3,7 @@ package main
|
||||
// register containerd builtins here
|
||||
import (
|
||||
_ "github.com/containerd/containerd/diff/walking"
|
||||
_ "github.com/containerd/containerd/gc/scheduler"
|
||||
_ "github.com/containerd/containerd/services/containers"
|
||||
_ "github.com/containerd/containerd/services/content"
|
||||
_ "github.com/containerd/containerd/services/diff"
|
||||
|
||||
@@ -270,8 +270,14 @@ var removeCommand = cli.Command{
|
||||
Name: "remove",
|
||||
Aliases: []string{"rm"},
|
||||
Usage: "remove one or more images by reference",
|
||||
ArgsUsage: "<ref> [<ref>, ...]",
|
||||
ArgsUsage: "[flags] <ref> [<ref>, ...]",
|
||||
Description: "remove one or more images by reference",
|
||||
Flags: []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "sync",
|
||||
Usage: "Synchronously remove image and all associated resources",
|
||||
},
|
||||
},
|
||||
Action: func(context *cli.Context) error {
|
||||
client, ctx, cancel, err := commands.NewClient(context)
|
||||
if err != nil {
|
||||
@@ -282,8 +288,12 @@ var removeCommand = cli.Command{
|
||||
exitErr error
|
||||
imageStore = client.ImageService()
|
||||
)
|
||||
for _, target := range context.Args() {
|
||||
if err := imageStore.Delete(ctx, target); err != nil {
|
||||
for i, target := range context.Args() {
|
||||
var opts []images.DeleteOpt
|
||||
if context.Bool("sync") && i == context.NArg()-1 {
|
||||
opts = append(opts, images.SynchronousDelete())
|
||||
}
|
||||
if err := imageStore.Delete(ctx, target, opts...); err != nil {
|
||||
if !errdefs.IsNotFound(err) {
|
||||
if exitErr == nil {
|
||||
exitErr = errors.Wrapf(err, "unable to delete %v", target)
|
||||
|
||||
Reference in New Issue
Block a user