mirror of https://github.com/docker/docs.git
Merge pull request #39 from crosbymichael/add-driver-flag
Add flag to set default graph driver
This commit is contained in:
commit
76f54f3a28
|
|
@ -16,6 +16,7 @@ type DaemonConfig struct {
|
||||||
BridgeIface string
|
BridgeIface string
|
||||||
DefaultIp net.IP
|
DefaultIp net.IP
|
||||||
InterContainerCommunication bool
|
InterContainerCommunication bool
|
||||||
|
GraphDriver string
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConfigFromJob creates and returns a new DaemonConfig object
|
// ConfigFromJob creates and returns a new DaemonConfig object
|
||||||
|
|
@ -37,5 +38,6 @@ func ConfigFromJob(job *engine.Job) *DaemonConfig {
|
||||||
}
|
}
|
||||||
config.DefaultIp = net.ParseIP(job.Getenv("DefaultIp"))
|
config.DefaultIp = net.ParseIP(job.Getenv("DefaultIp"))
|
||||||
config.InterContainerCommunication = job.GetenvBool("InterContainerCommunication")
|
config.InterContainerCommunication = job.GetenvBool("InterContainerCommunication")
|
||||||
|
config.GraphDriver = job.Getenv("GraphDriver")
|
||||||
return &config
|
return &config
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ func main() {
|
||||||
flEnableIptables := flag.Bool("iptables", true, "Disable iptables within docker")
|
flEnableIptables := flag.Bool("iptables", true, "Disable iptables within docker")
|
||||||
flDefaultIp := flag.String("ip", "0.0.0.0", "Default ip address to use when binding a containers ports")
|
flDefaultIp := flag.String("ip", "0.0.0.0", "Default ip address to use when binding a containers ports")
|
||||||
flInterContainerComm := flag.Bool("icc", true, "Enable inter-container communication")
|
flInterContainerComm := flag.Bool("icc", true, "Enable inter-container communication")
|
||||||
|
flGraphDriver := flag.String("graph-driver", "", "For docker to use a specific graph driver")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
|
@ -82,6 +83,7 @@ func main() {
|
||||||
job.Setenv("BridgeIface", *bridgeName)
|
job.Setenv("BridgeIface", *bridgeName)
|
||||||
job.Setenv("DefaultIp", *flDefaultIp)
|
job.Setenv("DefaultIp", *flDefaultIp)
|
||||||
job.SetenvBool("InterContainerCommunication", *flInterContainerComm)
|
job.SetenvBool("InterContainerCommunication", *flInterContainerComm)
|
||||||
|
job.Setenv("GraphDriver", *flGraphDriver)
|
||||||
if err := job.Run(); err != nil {
|
if err := job.Run(); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import (
|
||||||
"path"
|
"path"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var DefaultDriver string
|
||||||
|
|
||||||
type InitFunc func(root string) (Driver, error)
|
type InitFunc func(root string) (Driver, error)
|
||||||
|
|
||||||
type Driver interface {
|
type Driver interface {
|
||||||
|
|
@ -64,10 +66,16 @@ func GetDriver(name, home string) (Driver, error) {
|
||||||
func New(root string) (Driver, error) {
|
func New(root string) (Driver, error) {
|
||||||
var driver Driver
|
var driver Driver
|
||||||
var lastError error
|
var lastError error
|
||||||
// Use environment variable DOCKER_DRIVER to force a choice of driver
|
|
||||||
if name := os.Getenv("DOCKER_DRIVER"); name != "" {
|
for _, name := range []string{
|
||||||
return GetDriver(name, root)
|
os.Getenv("DOCKER_DRIVER"),
|
||||||
|
DefaultDriver,
|
||||||
|
} {
|
||||||
|
if name != "" {
|
||||||
|
return GetDriver(name, root)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for priority drivers first
|
// Check for priority drivers first
|
||||||
for _, name := range priority {
|
for _, name := range priority {
|
||||||
driver, lastError = GetDriver(name, root)
|
driver, lastError = GetDriver(name, root)
|
||||||
|
|
|
||||||
|
|
@ -637,6 +637,10 @@ func NewRuntime(config *DaemonConfig) (*Runtime, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRuntimeFromDirectory(config *DaemonConfig) (*Runtime, error) {
|
func NewRuntimeFromDirectory(config *DaemonConfig) (*Runtime, error) {
|
||||||
|
|
||||||
|
// Set the default driver
|
||||||
|
graphdriver.DefaultDriver = config.GraphDriver
|
||||||
|
|
||||||
// Load storage driver
|
// Load storage driver
|
||||||
driver, err := graphdriver.New(config.Root)
|
driver, err := graphdriver.New(config.Root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue