Parcourir la source

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>
Lei Jitang il y a 8 ans
Parent
commit
238ad8c36a
1 fichiers modifiés avec 4 ajouts et 0 suppressions
  1. 4 0
      daemon/logs.go

+ 4 - 0
daemon/logs.go

@@ -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
 	}