summaryrefslogtreecommitdiff
path: root/pkg/adapter/containers.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/adapter/containers.go')
-rw-r--r--pkg/adapter/containers.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go
index 47db5c0dc..afca4c948 100644
--- a/pkg/adapter/containers.go
+++ b/pkg/adapter/containers.go
@@ -205,7 +205,22 @@ func (r *LocalRuntime) RemoveContainers(ctx context.Context, cli *cliconfig.RmVa
ctrs, err := shortcuts.GetContainersByContext(cli.All, cli.Latest, cli.InputArgs, r.Runtime)
if err != nil {
- return ok, failures, err
+ // Failed to get containers. If force is specified, get the containers ID
+ // and evict them
+ if !cli.Force {
+ return ok, failures, err
+ }
+
+ for _, ctr := range cli.InputArgs {
+ logrus.Debugf("Evicting container %q", ctr)
+ id, err := r.EvictContainer(ctx, ctr, cli.Volumes)
+ if err != nil {
+ failures[ctr] = errors.Wrapf(err, "Failed to evict container: %q", id)
+ continue
+ }
+ ok = append(ok, id)
+ }
+ return ok, failures, nil
}
pool := shared.NewPool("rm", maxWorkers, len(ctrs))