diff --git a/config.go b/config.go index 75cd0c753f..eb00e41fa1 100644 --- a/config.go +++ b/config.go @@ -16,6 +16,7 @@ type DaemonConfig struct { BridgeIface string DefaultIp net.IP InterContainerCommunication bool + GraphDriver string } // 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.InterContainerCommunication = job.GetenvBool("InterContainerCommunication") + config.GraphDriver = job.Getenv("GraphDriver") return &config } diff --git a/docker/docker.go b/docker/docker.go index d7d46fff1a..e0fe6d1aa5 100644 --- a/docker/docker.go +++ b/docker/docker.go @@ -38,6 +38,7 @@ func main() { 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") flInterContainerComm := flag.Bool("icc", true, "Enable inter-container communication") + flGraphDriver := flag.String("graph-driver", "", "For docker to use a specific graph driver") flag.Parse() @@ -82,6 +83,7 @@ func main() { job.Setenv("BridgeIface", *bridgeName) job.Setenv("DefaultIp", *flDefaultIp) job.SetenvBool("InterContainerCommunication", *flInterContainerComm) + job.Setenv("GraphDriver", *flGraphDriver) if err := job.Run(); err != nil { log.Fatal(err) } diff --git a/graphdriver/driver.go b/graphdriver/driver.go index 914c6d7623..4359f10256 100644 --- a/graphdriver/driver.go +++ b/graphdriver/driver.go @@ -4,10 +4,11 @@ import ( "fmt" "github.com/dotcloud/docker/archive" "github.com/dotcloud/docker/utils" - "os" "path" ) +var DefaultDriver string + type InitFunc func(root string) (Driver, error) type Driver interface { @@ -64,9 +65,9 @@ func GetDriver(name, home string) (Driver, error) { func New(root string) (Driver, error) { var driver Driver var lastError error - // Use environment variable DOCKER_DRIVER to force a choice of driver - if name := os.Getenv("DOCKER_DRIVER"); name != "" { - return GetDriver(name, root) + + if DefaultDriver != "" { + return GetDriver(DefaultDriver, root) } // Check for priority drivers first for _, name := range priority { diff --git a/runtime.go b/runtime.go index 80e955d4a3..4295d27db8 100644 --- a/runtime.go +++ b/runtime.go @@ -637,6 +637,10 @@ func NewRuntime(config *DaemonConfig) (*Runtime, error) { } func NewRuntimeFromDirectory(config *DaemonConfig) (*Runtime, error) { + + // Set the default driver + graphdriver.DefaultDriver = config.GraphDriver + // Load storage driver driver, err := graphdriver.New(config.Root) if err != nil {