mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Send "Name" and "ID" when stating stopped containers
When `docker stats` stopped containers, client will get empty stats data, this commit will gurantee client always get "Name" and "ID" field, so that it can format with `ID` and `Name` fields successfully. Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
This commit is contained in:
@@ -33,7 +33,9 @@ func (daemon *Daemon) ContainerStats(ctx context.Context, prefixOrName string, c
|
||||
|
||||
// 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{})
|
||||
return json.NewEncoder(config.OutStream).Encode(&types.StatsJSON{
|
||||
Name: container.Name,
|
||||
ID: container.ID})
|
||||
}
|
||||
|
||||
outStream := config.OutStream
|
||||
|
||||
Reference in New Issue
Block a user