Fix docker logs a dead container

If a container is dead or marked for removal, the json log
file could have been removed, so docker logs will return
`<id>-json.log: no such file or directory`.

Signed-off-by: Lei Jitang <leijitang@huawei.com>
Upstream-commit: 238ad8c36a57d5484aa21efa26a8244aa4b8dff7
Component: engine
This commit is contained in:
Lei Jitang
2017-03-24 21:20:52 -04:00
parent dd50f0df64
commit 892701d23b
+4
View File
@@ -29,6 +29,10 @@ func (daemon *Daemon) ContainerLogs(ctx context.Context, containerName string, c
return err
}
if container.RemovalInProgress || container.Dead {
return errors.New("can not get logs from container which is dead or marked for removal")
}
if container.HostConfig.LogConfig.Type == "none" {
return logger.ErrReadLogsNotSupported
}