Skip to content

Commit d06f137

Browse files
authored
Merge pull request #4934 from thaJeztah/stats_improve
cli/command/container: use ping-result for OS-version
2 parents b55cf2f + 5c54f75 commit d06f137

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

Diff for: cli/command/container/stats.go

+6-9
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,6 @@ var acceptedStatsFilters = map[string]bool{
106106
func RunStats(ctx context.Context, dockerCLI command.Cli, options *StatsOptions) error {
107107
apiClient := dockerCLI.Client()
108108

109-
// Get the daemonOSType if not set already
110-
if daemonOSType == "" {
111-
sv, err := apiClient.ServerVersion(ctx)
112-
if err != nil {
113-
return err
114-
}
115-
daemonOSType = sv.Os
116-
}
117-
118109
// waitFirst is a WaitGroup to wait first stat data's reach for each container
119110
waitFirst := &sync.WaitGroup{}
120111
// closeChan is a non-buffered channel used to collect errors from goroutines.
@@ -267,6 +258,12 @@ func RunStats(ctx context.Context, dockerCLI command.Cli, options *StatsOptions)
267258
format = formatter.TableFormatKey
268259
}
269260
}
261+
if daemonOSType == "" {
262+
// Get the daemonOSType if not set already. The daemonOSType variable
263+
// should already be set when collecting stats as part of "collect()",
264+
// so we unlikely hit this code in practice.
265+
daemonOSType = dockerCLI.ServerInfo().OSType
266+
}
270267
statsCtx := formatter.Context{
271268
Output: dockerCLI.Out(),
272269
Format: NewStatsFormat(format, daemonOSType),

0 commit comments

Comments
 (0)