github.com/moby/docker@v26.1.3+incompatible/runconfig/hostconfig_windows.go (about) 1 package runconfig // import "github.com/docker/docker/runconfig" 2 3 import ( 4 "fmt" 5 6 "github.com/docker/docker/api/types/container" 7 "github.com/docker/docker/api/types/network" 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 network.NetworkNat 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 err := validateNetContainerMode(c, hc); err != nil { 26 return err 27 } 28 if hc.NetworkMode.IsContainer() && hc.Isolation.IsHyperV() { 29 return fmt.Errorf("Using the network stack of another container is not supported while using Hyper-V Containers") 30 } 31 return nil 32 } 33 34 // validateIsolation performs platform specific validation of the 35 // isolation in the hostconfig structure. Windows supports 'default' (or 36 // blank), 'process', or 'hyperv'. 37 func validateIsolation(hc *container.HostConfig) error { 38 if !hc.Isolation.IsValid() { 39 return fmt.Errorf("Invalid isolation: %q. Windows supports 'default', 'process', or 'hyperv'", hc.Isolation) 40 } 41 return nil 42 } 43 44 // validateQoS performs platform specific validation of the Qos settings 45 func validateQoS(_ *container.HostConfig) error { 46 return nil 47 } 48 49 // validateResources performs platform specific validation of the resource settings 50 func validateResources(hc *container.HostConfig, _ *sysinfo.SysInfo) error { 51 if hc.Resources.CPURealtimePeriod != 0 { 52 return fmt.Errorf("Windows does not support CPU real-time period") 53 } 54 if hc.Resources.CPURealtimeRuntime != 0 { 55 return fmt.Errorf("Windows does not support CPU real-time runtime") 56 } 57 return nil 58 } 59 60 // validatePrivileged performs platform specific validation of the Privileged setting 61 func validatePrivileged(hc *container.HostConfig) error { 62 if hc.Privileged { 63 return fmt.Errorf("Windows does not support privileged mode") 64 } 65 return nil 66 } 67 68 // validateReadonlyRootfs performs platform specific validation of the ReadonlyRootfs setting 69 func validateReadonlyRootfs(hc *container.HostConfig) error { 70 if hc.ReadonlyRootfs { 71 return fmt.Errorf("Windows does not support root filesystem in read-only mode") 72 } 73 return nil 74 }