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.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go
index 8be4d9d31..eb90ab50e 100644
--- a/pkg/adapter/containers.go
+++ b/pkg/adapter/containers.go
@@ -913,3 +913,30 @@ func cleanupContainer(ctx context.Context, ctr *libpod.Container, runtime *Local
}
return nil
}
+
+// Port displays port information about existing containers
+func (r *LocalRuntime) Port(c *cliconfig.PortValues) ([]*Container, error) {
+ var (
+ portContainers []*Container
+ containers []*libpod.Container
+ err error
+ )
+
+ if !c.All {
+ containers, err = shortcuts.GetContainersByContext(false, c.Latest, c.InputArgs, r.Runtime)
+ } else {
+ containers, err = r.Runtime.GetRunningContainers()
+ }
+ if err != nil {
+ return nil, err
+ }
+
+ //Convert libpod containers to adapter Containers
+ for _, con := range containers {
+ if state, _ := con.State(); state != libpod.ContainerStateRunning {
+ continue
+ }
+ portContainers = append(portContainers, &Container{con})
+ }
+ return portContainers, nil
+}