config_windows.go 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package config // import "github.com/docker/docker/daemon/config"
  2. import (
  3. "context"
  4. "os"
  5. "path/filepath"
  6. "github.com/containerd/log"
  7. )
  8. const (
  9. // StockRuntimeName is used by the 'default-runtime' flag in dockerd as the
  10. // default value. On Windows keep this empty so the value is auto-detected
  11. // based on other options.
  12. StockRuntimeName = ""
  13. // minAPIVersion represents Minimum REST API version supported
  14. // Technically the first daemon API version released on Windows is v1.25 in
  15. // engine version 1.13. However, some clients are explicitly using downlevel
  16. // APIs (e.g. docker-compose v2.1 file format) and that is just too restrictive.
  17. // Hence also allowing 1.24 on Windows.
  18. minAPIVersion string = "1.24"
  19. )
  20. // BridgeConfig is meant to store all the parameters for both the bridge driver and the default bridge network. On
  21. // Windows: 1. "bridge" in this context reference the nat driver and the default nat network; 2. the nat driver has no
  22. // specific parameters, so this struct effectively just stores parameters for the default nat network.
  23. type BridgeConfig struct {
  24. DefaultBridgeConfig
  25. }
  26. type DefaultBridgeConfig struct {
  27. commonBridgeConfig
  28. // MTU is not actually used on Windows, but the --mtu option has always
  29. // been there on Windows (but ignored).
  30. MTU int `json:"mtu,omitempty"`
  31. }
  32. // Config defines the configuration of a docker daemon.
  33. // It includes json tags to deserialize configuration from a file
  34. // using the same names that the flags in the command line uses.
  35. type Config struct {
  36. CommonConfig
  37. // Fields below here are platform specific. (There are none presently
  38. // for the Windows daemon.)
  39. }
  40. // GetExecRoot returns the user configured Exec-root
  41. func (conf *Config) GetExecRoot() string {
  42. return ""
  43. }
  44. // GetInitPath returns the configured docker-init path
  45. func (conf *Config) GetInitPath() string {
  46. return ""
  47. }
  48. // IsSwarmCompatible defines if swarm mode can be enabled in this config
  49. func (conf *Config) IsSwarmCompatible() error {
  50. return nil
  51. }
  52. // ValidatePlatformConfig checks if any platform-specific configuration settings are invalid.
  53. func (conf *Config) ValidatePlatformConfig() error {
  54. if conf.MTU != 0 && conf.MTU != DefaultNetworkMtu {
  55. log.G(context.TODO()).Warn(`WARNING: MTU for the default network is not configurable on Windows, and this option will be ignored.`)
  56. }
  57. return nil
  58. }
  59. // IsRootless returns conf.Rootless on Linux but false on Windows
  60. func (conf *Config) IsRootless() bool {
  61. return false
  62. }
  63. func setPlatformDefaults(cfg *Config) error {
  64. cfg.Root = filepath.Join(os.Getenv("programdata"), "docker")
  65. cfg.ExecRoot = filepath.Join(os.Getenv("programdata"), "docker", "exec-root")
  66. cfg.Pidfile = filepath.Join(cfg.Root, "docker.pid")
  67. return nil
  68. }