diff options
Diffstat (limited to 'cmd/podman/logs.go')
-rw-r--r-- | cmd/podman/logs.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cmd/podman/logs.go b/cmd/podman/logs.go index 07d95aaf8..1183abaa2 100644 --- a/cmd/podman/logs.go +++ b/cmd/podman/logs.go @@ -129,14 +129,14 @@ func logsCmd(c *cli.Context) error { defer file.Close() reader := bufio.NewReader(file) if opts.follow { - followLog(reader, opts) + followLog(reader, opts, ctr) } else { dumpLog(reader, opts) } return err } -func followLog(reader *bufio.Reader, opts logOptions) error { +func followLog(reader *bufio.Reader, opts logOptions, ctr *libpod.Container) error { var cacheOutput []string firstPass := false if opts.tail > 0 { @@ -161,6 +161,14 @@ func followLog(reader *bufio.Reader, opts logOptions) error { continue } time.Sleep(1 * time.Second) + // Check if container is still running or paused + state, err := ctr.State() + if err != nil { + return err + } + if state != libpod.ContainerStateRunning && state != libpod.ContainerStatePaused { + break + } continue } // exits |