cli/command/container: use per-stats OSType if present
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -109,6 +109,8 @@ func RunStats(ctx context.Context, dockerCLI command.Cli, options *StatsOptions)
|
||||
apiClient := dockerCLI.Client()
|
||||
|
||||
// Get the daemonOSType to handle platform-specific stats fields.
|
||||
// This value is used as a fallback for docker < v29, which did not
|
||||
// include the OSType field per stats.
|
||||
daemonOSType = dockerCLI.ServerInfo().OSType
|
||||
|
||||
// waitFirst is a WaitGroup to wait first stat data's reach for each container
|
||||
|
||||
@ -88,6 +88,12 @@ func collect(ctx context.Context, s *Stats, cli client.ContainerAPIClient, strea
|
||||
continue
|
||||
}
|
||||
|
||||
// Daemon versions before v29 did not return per-stats OSType;
|
||||
// fall back to using the daemon's OSType.
|
||||
if v.OSType == "" {
|
||||
v.OSType = daemonOSType
|
||||
}
|
||||
|
||||
if daemonOSType == "windows" {
|
||||
netRx, netTx := calculateNetwork(v.Networks)
|
||||
s.SetStatistics(StatsEntry{
|
||||
|
||||
Reference in New Issue
Block a user