hostconfig_windows.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package runconfig // import "github.com/docker/docker/runconfig"
  2. import (
  3. "fmt"
  4. "github.com/docker/docker/api/types/container"
  5. "github.com/docker/docker/api/types/network"
  6. "github.com/docker/docker/pkg/sysinfo"
  7. )
  8. // DefaultDaemonNetworkMode returns the default network stack the daemon should
  9. // use.
  10. func DefaultDaemonNetworkMode() container.NetworkMode {
  11. return network.NetworkNat
  12. }
  13. // IsPreDefinedNetwork indicates if a network is predefined by the daemon
  14. func IsPreDefinedNetwork(network string) bool {
  15. return !container.NetworkMode(network).IsUserDefined()
  16. }
  17. // validateNetMode ensures that the various combinations of requested
  18. // network settings are valid.
  19. func validateNetMode(c *container.Config, hc *container.HostConfig) error {
  20. if err := validateNetContainerMode(c, hc); err != nil {
  21. return err
  22. }
  23. if hc.NetworkMode.IsContainer() && hc.Isolation.IsHyperV() {
  24. return fmt.Errorf("Using the network stack of another container is not supported while using Hyper-V Containers")
  25. }
  26. return nil
  27. }
  28. // validateIsolation performs platform specific validation of the
  29. // isolation in the hostconfig structure. Windows supports 'default' (or
  30. // blank), 'process', or 'hyperv'.
  31. func validateIsolation(hc *container.HostConfig) error {
  32. if !hc.Isolation.IsValid() {
  33. return fmt.Errorf("Invalid isolation: %q. Windows supports 'default', 'process', or 'hyperv'", hc.Isolation)
  34. }
  35. return nil
  36. }
  37. // validateQoS performs platform specific validation of the Qos settings
  38. func validateQoS(_ *container.HostConfig) error {
  39. return nil
  40. }
  41. // validateResources performs platform specific validation of the resource settings
  42. func validateResources(hc *container.HostConfig, _ *sysinfo.SysInfo) error {
  43. if hc.Resources.CPURealtimePeriod != 0 {
  44. return fmt.Errorf("Windows does not support CPU real-time period")
  45. }
  46. if hc.Resources.CPURealtimeRuntime != 0 {
  47. return fmt.Errorf("Windows does not support CPU real-time runtime")
  48. }
  49. return nil
  50. }
  51. // validatePrivileged performs platform specific validation of the Privileged setting
  52. func validatePrivileged(hc *container.HostConfig) error {
  53. if hc.Privileged {
  54. return fmt.Errorf("Windows does not support privileged mode")
  55. }
  56. return nil
  57. }
  58. // validateReadonlyRootfs performs platform specific validation of the ReadonlyRootfs setting
  59. func validateReadonlyRootfs(hc *container.HostConfig) error {
  60. if hc.ReadonlyRootfs {
  61. return fmt.Errorf("Windows does not support root filesystem in read-only mode")
  62. }
  63. return nil
  64. }