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