github.com/csfrancis/docker@v1.8.0-rc2/runconfig/hostconfig_unix.go (about) 1 // +build !windows 2 3 package runconfig 4 5 import ( 6 "strings" 7 ) 8 9 // IsPrivate indicates whether container use it's private network stack 10 func (n NetworkMode) IsPrivate() bool { 11 return !(n.IsHost() || n.IsContainer()) 12 } 13 14 func (n NetworkMode) IsDefault() bool { 15 return n == "default" 16 } 17 18 func DefaultDaemonNetworkMode() NetworkMode { 19 return NetworkMode("bridge") 20 } 21 22 func (n NetworkMode) NetworkName() string { 23 if n.IsBridge() { 24 return "bridge" 25 } else if n.IsHost() { 26 return "host" 27 } else if n.IsContainer() { 28 return "container" 29 } else if n.IsNone() { 30 return "none" 31 } else if n.IsDefault() { 32 return "default" 33 } 34 return "" 35 } 36 37 func (n NetworkMode) IsBridge() bool { 38 return n == "bridge" 39 } 40 41 func (n NetworkMode) IsHost() bool { 42 return n == "host" 43 } 44 45 func (n NetworkMode) IsContainer() bool { 46 parts := strings.SplitN(string(n), ":", 2) 47 return len(parts) > 1 && parts[0] == "container" 48 } 49 50 func (n NetworkMode) IsNone() bool { 51 return n == "none" 52 }