mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Add support for Names and ID in stats format
This adds support to display names or id of container instead of what was provided in the request. This keeps the default behavior (`docker stats byname` will display `byname` in the `CONTAINER` colmun and `docker stats byid` will display the id in the `CONTAINER` column) but adds two new format directive. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
@@ -44,6 +44,8 @@ func (daemon *Daemon) ContainerStats(ctx context.Context, prefixOrName string, c
|
||||
var preRead time.Time
|
||||
getStatJSON := func(v interface{}) *types.StatsJSON {
|
||||
ss := v.(types.StatsJSON)
|
||||
ss.Name = container.Name
|
||||
ss.ID = container.ID
|
||||
ss.PreCPUStats = preCPUStats
|
||||
ss.PreRead = preRead
|
||||
preCPUStats = ss.CPUStats
|
||||
|
||||
Reference in New Issue
Block a user