config_unix.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // +build linux freebsd
  2. package config
  3. import (
  4. "fmt"
  5. "github.com/docker/docker/opts"
  6. units "github.com/docker/go-units"
  7. )
  8. // Config defines the configuration of a docker daemon.
  9. // It includes json tags to deserialize configuration from a file
  10. // using the same names that the flags in the command line uses.
  11. type Config struct {
  12. CommonConfig
  13. // These fields are common to all unix platforms.
  14. CommonUnixConfig
  15. // Fields below here are platform specific.
  16. CgroupParent string `json:"cgroup-parent,omitempty"`
  17. EnableSelinuxSupport bool `json:"selinux-enabled,omitempty"`
  18. RemappedRoot string `json:"userns-remap,omitempty"`
  19. Ulimits map[string]*units.Ulimit `json:"default-ulimits,omitempty"`
  20. CPURealtimePeriod int64 `json:"cpu-rt-period,omitempty"`
  21. CPURealtimeRuntime int64 `json:"cpu-rt-runtime,omitempty"`
  22. OOMScoreAdjust int `json:"oom-score-adjust,omitempty"`
  23. Init bool `json:"init,omitempty"`
  24. InitPath string `json:"init-path,omitempty"`
  25. SeccompProfile string `json:"seccomp-profile,omitempty"`
  26. ShmSize opts.MemBytes `json:"default-shm-size,omitempty"`
  27. }
  28. // BridgeConfig stores all the bridge driver specific
  29. // configuration.
  30. type BridgeConfig struct {
  31. commonBridgeConfig
  32. // These fields are common to all unix platforms.
  33. commonUnixBridgeConfig
  34. // Fields below here are platform specific.
  35. EnableIPv6 bool `json:"ipv6,omitempty"`
  36. EnableIPTables bool `json:"iptables,omitempty"`
  37. EnableIPForward bool `json:"ip-forward,omitempty"`
  38. EnableIPMasq bool `json:"ip-masq,omitempty"`
  39. EnableUserlandProxy bool `json:"userland-proxy,omitempty"`
  40. UserlandProxyPath string `json:"userland-proxy-path,omitempty"`
  41. FixedCIDRv6 string `json:"fixed-cidr-v6,omitempty"`
  42. }
  43. // IsSwarmCompatible defines if swarm mode can be enabled in this config
  44. func (conf *Config) IsSwarmCompatible() error {
  45. if conf.ClusterStore != "" || conf.ClusterAdvertise != "" {
  46. return fmt.Errorf("--cluster-store and --cluster-advertise daemon configurations are incompatible with swarm mode")
  47. }
  48. if conf.LiveRestoreEnabled {
  49. return fmt.Errorf("--live-restore daemon configuration is incompatible with swarm mode")
  50. }
  51. return nil
  52. }