Skip to content

Commit

Permalink
Return an empty stats if the container is restarting
Browse files Browse the repository at this point in the history
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 moby#27772.

Signed-off-by: Boaz Shuster <ripcurld.github@gmail.com>
  • Loading branch information
boaz0 committed Nov 3, 2016
1 parent 1f41378 commit 786a954
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions daemon/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
}

Expand Down

0 comments on commit 786a954

Please sign in to comment.