Skip to content

Commit

Permalink
Fix network info for docker containers running with --net=host.
Browse files Browse the repository at this point in the history
Docker still reports a loop device for these. Need to check for
more than one device to mark network as available.
  • Loading branch information
rjnagal committed Aug 24, 2015
1 parent 374e36d commit 7a2f508
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion container/docker/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,16 @@ func libcontainerConfigToContainerSpec(config *libcontainerConfigs.Config, mi *i
}
spec.Cpu.Mask = utils.FixCpuMask(config.Cgroups.CpusetCpus, mi.NumCores)

spec.HasNetwork = len(config.Networks) > 0
// Docker reports a loop device for containers with --net=host. Ignore
// those too.
networkCount := 0
for _, n := range config.Networks {
if n.Type != "loopback" {
networkCount += 1
}
}

spec.HasNetwork = networkCount > 0
spec.HasDiskIo = true

return spec
Expand Down

0 comments on commit 7a2f508

Please sign in to comment.