From 908aa5b4087ec5a4a257b9403e62e2850526f7a0 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Fri, 28 Oct 2016 11:48:25 -0700 Subject: [PATCH] Add StatsFormat to the config.json file As for `ps`, `images`, `network ls` and `volume ls`, this makes it possible to define a custom default format. Signed-off-by: Vincent Demeester --- command/container/stats.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/command/container/stats.go b/command/container/stats.go index e7954e4b98..5e743a4832 100644 --- a/command/container/stats.go +++ b/command/container/stats.go @@ -186,13 +186,17 @@ func runStats(dockerCli *command.DockerCli, opts *statsOptions) error { // before print to screen, make sure each container get at least one valid stat data waitFirst.Wait() - f := "table" - if len(opts.format) > 0 { - f = opts.format + format := opts.format + if len(format) == 0 { + if len(dockerCli.ConfigFile().StatsFormat) > 0 { + format = dockerCli.ConfigFile().StatsFormat + } else { + format = formatter.TableFormatKey + } } statsCtx := formatter.Context{ Output: dockerCli.Out(), - Format: formatter.NewStatsFormat(f, daemonOSType), + Format: formatter.NewStatsFormat(format, daemonOSType), } cleanScreen := func() { if !opts.noStream {