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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user