github.com/lazyboychen7/engine@v17.12.1-ce-rc2+incompatible/daemon/config/config_unix.go (about) 1 // +build linux freebsd 2 3 package config 4 5 import ( 6 "fmt" 7 8 containertypes "github.com/docker/docker/api/types/container" 9 "github.com/docker/docker/opts" 10 units "github.com/docker/go-units" 11 ) 12 13 const ( 14 // DefaultIpcMode is default for container's IpcMode, if not set otherwise 15 DefaultIpcMode = "shareable" // TODO: change to private 16 ) 17 18 // Config defines the configuration of a docker daemon. 19 // It includes json tags to deserialize configuration from a file 20 // using the same names that the flags in the command line uses. 21 type Config struct { 22 CommonConfig 23 24 // These fields are common to all unix platforms. 25 CommonUnixConfig 26 27 // Fields below here are platform specific. 28 CgroupParent string `json:"cgroup-parent,omitempty"` 29 EnableSelinuxSupport bool `json:"selinux-enabled,omitempty"` 30 RemappedRoot string `json:"userns-remap,omitempty"` 31 Ulimits map[string]*units.Ulimit `json:"default-ulimits,omitempty"` 32 CPURealtimePeriod int64 `json:"cpu-rt-period,omitempty"` 33 CPURealtimeRuntime int64 `json:"cpu-rt-runtime,omitempty"` 34 OOMScoreAdjust int `json:"oom-score-adjust,omitempty"` 35 Init bool `json:"init,omitempty"` 36 InitPath string `json:"init-path,omitempty"` 37 SeccompProfile string `json:"seccomp-profile,omitempty"` 38 ShmSize opts.MemBytes `json:"default-shm-size,omitempty"` 39 NoNewPrivileges bool `json:"no-new-privileges,omitempty"` 40 IpcMode string `json:"default-ipc-mode,omitempty"` 41 } 42 43 // BridgeConfig stores all the bridge driver specific 44 // configuration. 45 type BridgeConfig struct { 46 commonBridgeConfig 47 48 // These fields are common to all unix platforms. 49 commonUnixBridgeConfig 50 51 // Fields below here are platform specific. 52 EnableIPv6 bool `json:"ipv6,omitempty"` 53 EnableIPTables bool `json:"iptables,omitempty"` 54 EnableIPForward bool `json:"ip-forward,omitempty"` 55 EnableIPMasq bool `json:"ip-masq,omitempty"` 56 EnableUserlandProxy bool `json:"userland-proxy,omitempty"` 57 UserlandProxyPath string `json:"userland-proxy-path,omitempty"` 58 FixedCIDRv6 string `json:"fixed-cidr-v6,omitempty"` 59 } 60 61 // IsSwarmCompatible defines if swarm mode can be enabled in this config 62 func (conf *Config) IsSwarmCompatible() error { 63 if conf.ClusterStore != "" || conf.ClusterAdvertise != "" { 64 return fmt.Errorf("--cluster-store and --cluster-advertise daemon configurations are incompatible with swarm mode") 65 } 66 if conf.LiveRestoreEnabled { 67 return fmt.Errorf("--live-restore daemon configuration is incompatible with swarm mode") 68 } 69 return nil 70 } 71 72 func verifyDefaultIpcMode(mode string) error { 73 const hint = "Use \"shareable\" or \"private\"." 74 75 dm := containertypes.IpcMode(mode) 76 if !dm.Valid() { 77 return fmt.Errorf("Default IPC mode setting (%v) is invalid. "+hint, dm) 78 } 79 if dm != "" && !dm.IsPrivate() && !dm.IsShareable() { 80 return fmt.Errorf("IPC mode \"%v\" is not supported as default value. "+hint, dm) 81 } 82 return nil 83 } 84 85 // ValidatePlatformConfig checks if any platform-specific configuration settings are invalid. 86 func (conf *Config) ValidatePlatformConfig() error { 87 return verifyDefaultIpcMode(conf.IpcMode) 88 }