Browse code

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>

Boaz Shuster authored on 2016/11/03 19:07:18
Showing 1 changed files
... ...
@@ -27,8 +27,8 @@ func (daemon *Daemon) ContainerStats(ctx context.Context, prefixOrName string, c
27 27
 		return err
28 28
 	}
29 29
 
30
-	// If the container is not running and requires no stream, return an empty stats.
31
-	if !container.IsRunning() && !config.Stream {
30
+	// If the container is either not running or restarting and requires no stream, return an empty stats.
31
+	if (!container.IsRunning() || container.IsRestarting()) && !config.Stream {
32 32
 		return json.NewEncoder(config.OutStream).Encode(&types.Stats{})
33 33
 	}
34 34