1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/config.go
Vincent Batts 5f84d7f314 execdriver flag for docker daemon
like the storage-driver flag, this implements a flag for choosing the
  execdriver to be used, defaulting to lxc.

Docker-DCO-1.1-Signed-off-by: Vincent Batts <vbatts@redhat.com> (github: vbatts)
2014-02-17 20:03:53 -05:00

67 lines
2 KiB
Go

package docker
import (
"net"
"github.com/dotcloud/docker/engine"
"github.com/dotcloud/docker/networkdriver"
)
const (
defaultNetworkMtu = 1500
DisableNetworkBridge = "none"
)
// FIXME: separate runtime configuration from http api configuration
type DaemonConfig struct {
Pidfile string
Root string
AutoRestart bool
Dns []string
EnableIptables bool
EnableIpForward bool
DefaultIp net.IP
BridgeIface string
BridgeIP string
InterContainerCommunication bool
GraphDriver string
ExecDriver string
Mtu int
DisableNetwork bool
}
// ConfigFromJob creates and returns a new DaemonConfig object
// by parsing the contents of a job's environment.
func DaemonConfigFromJob(job *engine.Job) *DaemonConfig {
config := &DaemonConfig{
Pidfile: job.Getenv("Pidfile"),
Root: job.Getenv("Root"),
AutoRestart: job.GetenvBool("AutoRestart"),
EnableIptables: job.GetenvBool("EnableIptables"),
EnableIpForward: job.GetenvBool("EnableIpForward"),
BridgeIP: job.Getenv("BridgeIP"),
BridgeIface: job.Getenv("BridgeIface"),
DefaultIp: net.ParseIP(job.Getenv("DefaultIp")),
InterContainerCommunication: job.GetenvBool("InterContainerCommunication"),
GraphDriver: job.Getenv("GraphDriver"),
ExecDriver: job.Getenv("ExecDriver"),
}
if dns := job.GetenvList("Dns"); dns != nil {
config.Dns = dns
}
if mtu := job.GetenvInt("Mtu"); mtu != 0 {
config.Mtu = mtu
} else {
config.Mtu = GetDefaultNetworkMtu()
}
config.DisableNetwork = config.BridgeIface == DisableNetworkBridge
return config
}
func GetDefaultNetworkMtu() int {
if iface, err := networkdriver.GetDefaultRouteIface(); err == nil {
return iface.MTU
}
return defaultNetworkMtu
}