Add flag to set default graph driver

Remove the env var DOCKER_DRIVER
This commit is contained in:
Michael Crosby 2013-11-14 23:02:09 -08:00
parent f6629bbbd5
commit 6dbeed89c0
4 changed files with 13 additions and 4 deletions

View File

@ -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
}

View File

@ -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)
}

View File

@ -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 {

View File

@ -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 {