summaryrefslogtreecommitdiff
path: root/libpod/container_log.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/container_log.go')
-rw-r--r--libpod/container_log.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/libpod/container_log.go b/libpod/container_log.go
index c3a84d048..36b89f1ae 100644
--- a/libpod/container_log.go
+++ b/libpod/container_log.go
@@ -30,6 +30,13 @@ func (c *Container) ReadLog(options *logs.LogOptions, logChannel chan *logs.LogL
}
func (c *Container) readFromLogFile(options *logs.LogOptions, logChannel chan *logs.LogLine) error {
+ state, err := c.State()
+ if err != nil {
+ return err
+ }
+ if state != define.ContainerStateRunning && state != define.ContainerStatePaused {
+ options.Follow = false
+ }
t, tailLog, err := logs.GetLogFile(c.LogPath(), options)
if err != nil {
// If the log file does not exist, this is not fatal.
@@ -69,6 +76,14 @@ func (c *Container) readFromLogFile(options *logs.LogOptions, logChannel chan *l
if nll.Since(options.Since) {
logChannel <- nll
}
+ state, err := c.State()
+ if err != nil {
+ logrus.Error(err)
+ break
+ }
+ if options.Follow && state != define.ContainerStateRunning && state != define.ContainerStatePaused {
+ t.Kill(err)
+ }
}
options.WaitGroup.Done()
}()