config_unix.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. NoNewPrivileges bool `json:"no-new-privileges,omitempty"`
  28. }
  29. // BridgeConfig stores all the bridge driver specific
  30. // configuration.
  31. type BridgeConfig struct {
  32. commonBridgeConfig
  33. // These fields are common to all unix platforms.
  34. commonUnixBridgeConfig
  35. // Fields below here are platform specific.
  36. EnableIPv6 bool `json:"ipv6,omitempty"`
  37. EnableIPTables bool `json:"iptables,omitempty"`
  38. EnableIPForward bool `json:"ip-forward,omitempty"`
  39. EnableIPMasq bool `json:"ip-masq,omitempty"`
  40. EnableUserlandProxy bool `json:"userland-proxy,omitempty"`
  41. UserlandProxyPath string `json:"userland-proxy-path,omitempty"`
  42. FixedCIDRv6 string `json:"fixed-cidr-v6,omitempty"`
  43. }
  44. // IsSwarmCompatible defines if swarm mode can be enabled in this config
  45. func (conf *Config) IsSwarmCompatible() error {
  46. if conf.ClusterStore != "" || conf.ClusterAdvertise != "" {
  47. return fmt.Errorf("--cluster-store and --cluster-advertise daemon configurations are incompatible with swarm mode")
  48. }
  49. if conf.LiveRestoreEnabled {
  50. return fmt.Errorf("--live-restore daemon configuration is incompatible with swarm mode")
  51. }
  52. return nil
  53. }