diff options
Diffstat (limited to 'cmd/podman/ps.go')
-rw-r--r-- | cmd/podman/ps.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go index be6c5aef5..0b75b9a96 100644 --- a/cmd/podman/ps.go +++ b/cmd/podman/ps.go @@ -427,9 +427,17 @@ func getTemplateOutput(containers []*libpod.Container, opts psOptions) ([]psTemp if batchErr != nil { return nil, err } - - runningFor := units.HumanDuration(time.Since(conConfig.CreatedTime)) - createdAt := runningFor + " ago" + runningFor := "" + startedTime, err := ctr.StartedTime() + if err != nil { + logrus.Errorf("error getting started time for %q: %v", ctr.ID(), err) + } + // If the container has not be started, the "zero" value of time is 0001-01-01 00:00:00 +0000 UTC + // which would make the time elapsed about a few hundred of years. So checking for the "zero" value of time.Time + if startedTime != (time.Time{}) { + runningFor = units.HumanDuration(time.Since(startedTime)) + } + createdAt := conConfig.CreatedTime.Format("2006-01-02 15:04:05 -0700 MST") imageName := conConfig.RootfsImageName rootFsSize, err := ctr.RootFsSize() if err != nil { |