2015-07-29 14:25:56 -04:00
|
|
|
// +build linux freebsd
|
|
|
|
|
2015-04-24 18:36:11 -04:00
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
2016-06-14 12:13:53 -04:00
|
|
|
"fmt"
|
2015-05-15 16:05:35 -04:00
|
|
|
|
2016-12-23 14:09:12 -05:00
|
|
|
"github.com/docker/docker/opts"
|
2016-06-21 16:42:47 -04:00
|
|
|
units "github.com/docker/go-units"
|
|
|
|
"github.com/spf13/pflag"
|
2015-04-24 18:36:11 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2016-03-18 14:50:19 -04:00
|
|
|
defaultPidFile = "/var/run/docker.pid"
|
|
|
|
defaultGraph = "/var/lib/docker"
|
|
|
|
defaultExecRoot = "/var/run/docker"
|
2016-12-25 04:11:12 -05:00
|
|
|
defaultShmSize = int64(67108864)
|
2015-04-24 18:36:11 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// Config defines the configuration of a docker daemon.
|
2015-12-10 18:35:10 -05:00
|
|
|
// It includes json tags to deserialize configuration from a file
|
|
|
|
// using the same names that the flags in the command line uses.
|
2015-04-24 18:36:11 -04:00
|
|
|
type Config struct {
|
|
|
|
CommonConfig
|
|
|
|
|
2016-06-07 03:45:21 -04:00
|
|
|
// These fields are common to all unix platforms.
|
|
|
|
CommonUnixConfig
|
|
|
|
|
2015-04-24 18:36:11 -04:00
|
|
|
// Fields below here are platform specific.
|
2016-03-24 14:42:03 -04:00
|
|
|
CgroupParent string `json:"cgroup-parent,omitempty"`
|
2015-12-10 18:35:10 -05:00
|
|
|
EnableSelinuxSupport bool `json:"selinux-enabled,omitempty"`
|
|
|
|
RemappedRoot string `json:"userns-remap,omitempty"`
|
|
|
|
Ulimits map[string]*units.Ulimit `json:"default-ulimits,omitempty"`
|
2016-06-07 15:05:43 -04:00
|
|
|
CPURealtimePeriod int64 `json:"cpu-rt-period,omitempty"`
|
|
|
|
CPURealtimeRuntime int64 `json:"cpu-rt-runtime,omitempty"`
|
2016-07-11 18:26:23 -04:00
|
|
|
OOMScoreAdjust int `json:"oom-score-adjust,omitempty"`
|
2016-06-27 17:38:47 -04:00
|
|
|
Init bool `json:"init,omitempty"`
|
2016-09-27 06:51:42 -04:00
|
|
|
InitPath string `json:"init-path,omitempty"`
|
2016-09-02 09:20:54 -04:00
|
|
|
SeccompProfile string `json:"seccomp-profile,omitempty"`
|
2016-12-25 04:11:12 -05:00
|
|
|
ShmSize opts.MemBytes `json:"default-shm-size,omitempty"`
|
2015-04-24 18:36:11 -04:00
|
|
|
}
|
|
|
|
|
2015-05-15 16:05:35 -04:00
|
|
|
// bridgeConfig stores all the bridge driver specific
|
|
|
|
// configuration.
|
|
|
|
type bridgeConfig struct {
|
2016-03-28 14:55:20 -04:00
|
|
|
commonBridgeConfig
|
|
|
|
|
2016-06-07 03:45:21 -04:00
|
|
|
// These fields are common to all unix platforms.
|
|
|
|
commonUnixBridgeConfig
|
|
|
|
|
2016-03-28 14:55:20 -04:00
|
|
|
// Fields below here are platform specific.
|
2016-06-07 03:45:21 -04:00
|
|
|
EnableIPv6 bool `json:"ipv6,omitempty"`
|
|
|
|
EnableIPTables bool `json:"iptables,omitempty"`
|
|
|
|
EnableIPForward bool `json:"ip-forward,omitempty"`
|
|
|
|
EnableIPMasq bool `json:"ip-masq,omitempty"`
|
|
|
|
EnableUserlandProxy bool `json:"userland-proxy,omitempty"`
|
|
|
|
UserlandProxyPath string `json:"userland-proxy-path,omitempty"`
|
|
|
|
FixedCIDRv6 string `json:"fixed-cidr-v6,omitempty"`
|
2015-05-15 16:05:35 -04:00
|
|
|
}
|
|
|
|
|
2016-06-21 16:42:47 -04:00
|
|
|
// InstallFlags adds flags to the pflag.FlagSet to configure the daemon
|
|
|
|
func (config *Config) InstallFlags(flags *pflag.FlagSet) {
|
2015-04-24 18:36:11 -04:00
|
|
|
// First handle install flags which are consistent cross-platform
|
2016-06-21 16:42:47 -04:00
|
|
|
config.InstallCommonFlags(flags)
|
2015-04-24 18:36:11 -04:00
|
|
|
|
2016-06-07 03:45:21 -04:00
|
|
|
// Then install flags common to unix platforms
|
|
|
|
config.InstallCommonUnixFlags(flags)
|
|
|
|
|
2015-12-21 15:06:46 -05:00
|
|
|
config.Ulimits = make(map[string]*units.Ulimit)
|
2015-10-08 11:51:41 -04:00
|
|
|
|
2016-12-25 04:11:12 -05:00
|
|
|
// Set default value for `--default-shm-size`
|
|
|
|
config.ShmSize = opts.MemBytes(defaultShmSize)
|
|
|
|
|
2016-06-21 16:42:47 -04:00
|
|
|
// Then platform-specific install flags
|
|
|
|
flags.BoolVar(&config.EnableSelinuxSupport, "selinux-enabled", false, "Enable selinux support")
|
2016-12-23 14:09:12 -05:00
|
|
|
flags.Var(opts.NewUlimitOpt(&config.Ulimits), "default-ulimit", "Default ulimits for containers")
|
2016-06-21 16:42:47 -04:00
|
|
|
flags.BoolVar(&config.bridgeConfig.EnableIPTables, "iptables", true, "Enable addition of iptables rules")
|
|
|
|
flags.BoolVar(&config.bridgeConfig.EnableIPForward, "ip-forward", true, "Enable net.ipv4.ip_forward")
|
|
|
|
flags.BoolVar(&config.bridgeConfig.EnableIPMasq, "ip-masq", true, "Enable IP masquerading")
|
|
|
|
flags.BoolVar(&config.bridgeConfig.EnableIPv6, "ipv6", false, "Enable IPv6 networking")
|
|
|
|
flags.StringVar(&config.ExecRoot, "exec-root", defaultExecRoot, "Root directory for execution state files")
|
|
|
|
flags.StringVar(&config.bridgeConfig.FixedCIDRv6, "fixed-cidr-v6", "", "IPv6 subnet for fixed IPs")
|
|
|
|
flags.BoolVar(&config.bridgeConfig.EnableUserlandProxy, "userland-proxy", true, "Use userland proxy for loopback traffic")
|
2016-09-24 09:44:25 -04:00
|
|
|
flags.StringVar(&config.bridgeConfig.UserlandProxyPath, "userland-proxy-path", "", "Path to the userland proxy binary")
|
2016-11-15 14:45:20 -05:00
|
|
|
flags.BoolVar(&config.EnableCors, "api-enable-cors", false, "Enable CORS headers in the Engine API, this is deprecated by --api-cors-header")
|
2016-06-21 16:42:47 -04:00
|
|
|
flags.MarkDeprecated("api-enable-cors", "Please use --api-cors-header")
|
|
|
|
flags.StringVar(&config.CgroupParent, "cgroup-parent", "", "Set parent cgroup for all containers")
|
|
|
|
flags.StringVar(&config.RemappedRoot, "userns-remap", "", "User/Group setting for user namespaces")
|
|
|
|
flags.StringVar(&config.ContainerdAddr, "containerd", "", "Path to containerd socket")
|
|
|
|
flags.BoolVar(&config.LiveRestoreEnabled, "live-restore", false, "Enable live restore of docker when containers are still running")
|
|
|
|
flags.IntVar(&config.OOMScoreAdjust, "oom-score-adjust", -500, "Set the oom_score_adj for the daemon")
|
2016-06-27 17:38:47 -04:00
|
|
|
flags.BoolVar(&config.Init, "init", false, "Run an init in the container to forward signals and reap processes")
|
2016-09-27 06:51:42 -04:00
|
|
|
flags.StringVar(&config.InitPath, "init-path", "", "Path to the docker-init binary")
|
2016-06-07 15:05:43 -04:00
|
|
|
flags.Int64Var(&config.CPURealtimePeriod, "cpu-rt-period", 0, "Limit the CPU real-time period in microseconds")
|
|
|
|
flags.Int64Var(&config.CPURealtimeRuntime, "cpu-rt-runtime", 0, "Limit the CPU real-time runtime in microseconds")
|
2016-09-02 09:20:54 -04:00
|
|
|
flags.StringVar(&config.SeccompProfile, "seccomp-profile", "", "Path to seccomp profile")
|
2016-12-25 04:11:12 -05:00
|
|
|
flags.Var(&config.ShmSize, "default-shm-size", "Default shm size for containers")
|
2016-06-21 16:42:47 -04:00
|
|
|
|
|
|
|
config.attachExperimentalFlags(flags)
|
2015-04-24 18:36:11 -04:00
|
|
|
}
|
2016-05-23 17:49:50 -04:00
|
|
|
|
2016-06-14 12:13:53 -04:00
|
|
|
func (config *Config) isSwarmCompatible() error {
|
2016-06-28 13:23:35 -04:00
|
|
|
if config.ClusterStore != "" || config.ClusterAdvertise != "" {
|
2016-06-14 12:13:53 -04:00
|
|
|
return fmt.Errorf("--cluster-store and --cluster-advertise daemon configurations are incompatible with swarm mode")
|
|
|
|
}
|
2016-07-27 11:30:15 -04:00
|
|
|
if config.LiveRestoreEnabled {
|
2016-06-14 12:13:53 -04:00
|
|
|
return fmt.Errorf("--live-restore daemon configuration is incompatible with swarm mode")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|