1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Return an empty stats if the container is restarting

In case, a container is restarting indefinitely running
"docker stats --no-stream <restarting_container>" is suspended.

To fix this, the daemon makes sure the container is either not
running or restarting if `--no-stream` is set to true and if so
returns an empty stats.

Should fix #27772.

Signed-off-by: Boaz Shuster <ripcurld.github@gmail.com>
(cherry picked from commit 786a95493d)
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
This commit is contained in:
Boaz Shuster 2016-11-03 12:07:18 +02:00 committed by Victor Vieux
parent cbff9474d2
commit c050ee1917

View file

@ -31,8 +31,8 @@ func (daemon *Daemon) ContainerStats(ctx context.Context, prefixOrName string, c
return err return err
} }
// If the container is not running and requires no stream, return an empty stats. // If the container is either not running or restarting and requires no stream, return an empty stats.
if !container.IsRunning() && !config.Stream { if (!container.IsRunning() || container.IsRestarting()) && !config.Stream {
return json.NewEncoder(config.OutStream).Encode(&types.Stats{}) return json.NewEncoder(config.OutStream).Encode(&types.Stats{})
} }