From 786a95493d54d74fa3eef020c1ec03baa4fe91c4 Mon Sep 17 00:00:00 2001 From: Boaz Shuster Date: Thu, 3 Nov 2016 12:07:18 +0200 Subject: [PATCH] Return an empty stats if the container is restarting In case, a container is restarting indefinitely running "docker stats --no-stream " 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 --- daemon/stats.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daemon/stats.go b/daemon/stats.go index 2db68525608a6..016dd9b8b7557 100644 --- a/daemon/stats.go +++ b/daemon/stats.go @@ -27,8 +27,8 @@ func (daemon *Daemon) ContainerStats(ctx context.Context, prefixOrName string, c return err } - // If the container is not running and requires no stream, return an empty stats. - if !container.IsRunning() && !config.Stream { + // If the container is either not running or restarting and requires no stream, return an empty stats. + if (!container.IsRunning() || container.IsRestarting()) && !config.Stream { return json.NewEncoder(config.OutStream).Encode(&types.Stats{}) }