summaryrefslogtreecommitdiff
path: root/pkg/adapter/containers_remote.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-04-20 12:58:59 -0500
committerbaude <bbaude@redhat.com>2019-04-26 10:15:09 -0500
commit2e800d63aa388bb248c97ea24fae2f7190fe3cce (patch)
treea802665cf02289f454e79f06a770e0b9ec54283d /pkg/adapter/containers_remote.go
parent135c8bef223d32f553659cbdfd5eb99f948a6c84 (diff)
downloadpodman-2e800d63aa388bb248c97ea24fae2f7190fe3cce.tar.gz
podman-2e800d63aa388bb248c97ea24fae2f7190fe3cce.tar.bz2
podman-2e800d63aa388bb248c97ea24fae2f7190fe3cce.zip
podman-remote prune containers
enable the ability to prune containers from the remote-command. this also includes the system prune command. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/adapter/containers_remote.go')
-rw-r--r--pkg/adapter/containers_remote.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/pkg/adapter/containers_remote.go b/pkg/adapter/containers_remote.go
index ef6d0efe1..93875dd8a 100644
--- a/pkg/adapter/containers_remote.go
+++ b/pkg/adapter/containers_remote.go
@@ -852,3 +852,31 @@ func (r *LocalRuntime) Top(cli *cliconfig.TopValues) ([]string, error) {
}
return iopodman.Top().Call(r.Conn, ctr.ID(), descriptors)
}
+
+// Prune removes stopped containers
+func (r *LocalRuntime) Prune(ctx context.Context, maxWorkers int, force bool) ([]string, map[string]error, error) {
+
+ var (
+ ok = []string{}
+ failures = map[string]error{}
+ ctrs []*Container
+ err error
+ )
+ logrus.Debugf("Setting maximum rm workers to %d", maxWorkers)
+
+ filters := []string{libpod.ContainerStateExited.String()}
+ ctrs, err = r.LookupContainersWithStatus(filters)
+ if err != nil {
+ return ok, failures, err
+ }
+ for _, c := range ctrs {
+ c := c
+ _, err := iopodman.RemoveContainer().Call(r.Conn, c.ID(), false, false)
+ if err != nil {
+ failures[c.ID()] = err
+ } else {
+ ok = append(ok, c.ID())
+ }
+ }
+ return ok, failures, nil
+}