github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/api/types/container/hostconfig_unix.go (about) 1 //go:build !windows 2 // +build !windows 3 4 package container // import "github.com/docker/docker/api/types/container" 5 6 // IsValid indicates if an isolation technology is valid 7 func (i Isolation) IsValid() bool { 8 return i.IsDefault() 9 } 10 11 // NetworkName returns the name of the network stack. 12 func (n NetworkMode) NetworkName() string { 13 if n.IsBridge() { 14 return "bridge" 15 } else if n.IsHost() { 16 return "host" 17 } else if n.IsContainer() { 18 return "container" 19 } else if n.IsNone() { 20 return "none" 21 } else if n.IsDefault() { 22 return "default" 23 } else if n.IsUserDefined() { 24 return n.UserDefined() 25 } 26 return "" 27 } 28 29 // IsBridge indicates whether container uses the bridge network stack 30 func (n NetworkMode) IsBridge() bool { 31 return n == "bridge" 32 } 33 34 // IsHost indicates whether container uses the host network stack. 35 func (n NetworkMode) IsHost() bool { 36 return n == "host" 37 } 38 39 // IsUserDefined indicates user-created network 40 func (n NetworkMode) IsUserDefined() bool { 41 return !n.IsDefault() && !n.IsBridge() && !n.IsHost() && !n.IsNone() && !n.IsContainer() 42 }