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>
This commit is contained in:
Lei Jitang 2017-03-24 03:55:55 -04:00
parent 8008f65293
commit 238ad8c36a

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
}