summaryrefslogtreecommitdiff
path: root/pkg/adapter/containers_remote.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-04-30 15:16:29 +0200
committerGitHub <noreply@github.com>2019-04-30 15:16:29 +0200
commit084e4e16a102bc48b3b5c060947f2d1c9d7e2e2f (patch)
tree9c0aef8150988204169a6eb19e299acda6dc8f96 /pkg/adapter/containers_remote.go
parenta2fd2d2c32c86b6fdee038312fe246bd1c825c7e (diff)
parent2e800d63aa388bb248c97ea24fae2f7190fe3cce (diff)
downloadpodman-084e4e16a102bc48b3b5c060947f2d1c9d7e2e2f.tar.gz
podman-084e4e16a102bc48b3b5c060947f2d1c9d7e2e2f.tar.bz2
podman-084e4e16a102bc48b3b5c060947f2d1c9d7e2e2f.zip
Merge pull request #2982 from baude/remotecontainerprune
podman-remote prune containers
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
+}