github.com/hms58/moby@v1.13.1/runconfig/hostconfig_windows.go (about) 1 package runconfig 2 3 import ( 4 "fmt" 5 "strings" 6 7 "github.com/docker/docker/api/types/container" 8 "github.com/docker/docker/pkg/sysinfo" 9 ) 10 11 // DefaultDaemonNetworkMode returns the default network stack the daemon should 12 // use. 13 func DefaultDaemonNetworkMode() container.NetworkMode { 14 return container.NetworkMode("nat") 15 } 16 17 // IsPreDefinedNetwork indicates if a network is predefined by the daemon 18 func IsPreDefinedNetwork(network string) bool { 19 return !container.NetworkMode(network).IsUserDefined() 20 } 21 22 // ValidateNetMode ensures that the various combinations of requested 23 // network settings are valid. 24 func ValidateNetMode(c *container.Config, hc *container.HostConfig) error { 25 if hc == nil { 26 return nil 27 } 28 parts := strings.Split(string(hc.NetworkMode), ":") 29 if len(parts) > 1 { 30 return fmt.Errorf("invalid --net: %s", hc.NetworkMode) 31 } 32 return nil 33 } 34 35 // ValidateIsolation performs platform specific validation of the 36 // isolation in the hostconfig structure. Windows supports 'default' (or 37 // blank), 'process', or 'hyperv'. 38 func ValidateIsolation(hc *container.HostConfig) error { 39 // We may not be passed a host config, such as in the case of docker commit 40 if hc == nil { 41 return nil 42 } 43 if !hc.Isolation.IsValid() { 44 return fmt.Errorf("invalid --isolation: %q. Windows supports 'default', 'process', or 'hyperv'", hc.Isolation) 45 } 46 return nil 47 } 48 49 // ValidateQoS performs platform specific validation of the Qos settings 50 func ValidateQoS(hc *container.HostConfig) error { 51 return nil 52 } 53 54 // ValidateResources performs platform specific validation of the resource settings 55 func ValidateResources(hc *container.HostConfig, si *sysinfo.SysInfo) error { 56 // We may not be passed a host config, such as in the case of docker commit 57 if hc == nil { 58 return nil 59 } 60 61 if hc.Resources.CPURealtimePeriod != 0 { 62 return fmt.Errorf("invalid --cpu-rt-period: Windows does not support this feature") 63 } 64 if hc.Resources.CPURealtimeRuntime != 0 { 65 return fmt.Errorf("invalid --cpu-rt-runtime: Windows does not support this feature") 66 } 67 return nil 68 }