mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Fix issue in docker stats with NetworkDisabled=true
This fix tries to address the issue in 25000 where `docker stats` will not show network stats with `NetworkDisabled=true`. The `NetworkDisabled=true` could be either invoked through remote API, or through `docker daemon -b none`. The issue was that when `NetworkDisabled=true` either by API or by daemon config, there is no SandboxKey for container so an error will be returned. This fix fixes this issue by skipping obtaining SandboxKey if `NetworkDisabled=true`. Additional test has bee added to cover the changes. This fix fixes 25000. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
@@ -138,8 +138,10 @@ func (daemon *Daemon) GetContainerStats(container *container.Container) (*types.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if stats.Networks, err = daemon.getNetworkStats(container); err != nil {
|
||||
return nil, err
|
||||
if !container.Config.NetworkDisabled {
|
||||
if stats.Networks, err = daemon.getNetworkStats(container); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return stats, nil
|
||||
|
||||
Reference in New Issue
Block a user