From e44f62a95cc8f3cab446205d66450ee37911e29c Mon Sep 17 00:00:00 2001 From: Eric Myhre Date: Thu, 20 Jun 2013 16:29:54 -0500 Subject: [PATCH] Add argument to allow setting base directory for docker daemon's storage to values other than "/var/lib/docker". --- docker/docker.go | 7 ++++--- runtime.go | 4 ++-- server.go | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docker/docker.go b/docker/docker.go index 6d79972bd6..87c2e7aa9c 100644 --- a/docker/docker.go +++ b/docker/docker.go @@ -30,6 +30,7 @@ func main() { flAutoRestart := flag.Bool("r", false, "Restart previously running containers") bridgeName := flag.String("b", "", "Attach containers to a pre-existing network bridge") pidfile := flag.String("p", "/var/run/docker.pid", "File containing process PID") + flGraphPath := flag.String("g", "/var/lib/docker", "Path to graph storage base dir.") flEnableCors := flag.Bool("api-enable-cors", false, "Enable CORS requests in the remote api.") flDns := flag.String("dns", "", "Set custom dns servers") flHosts := docker.ListOpts{fmt.Sprintf("tcp://%s:%d", docker.DEFAULTHTTPHOST, docker.DEFAULTHTTPPORT)} @@ -56,7 +57,7 @@ func main() { flag.Usage() return } - if err := daemon(*pidfile, flHosts, *flAutoRestart, *flEnableCors, *flDns); err != nil { + if err := daemon(*pidfile, *flGraphPath, flHosts, *flAutoRestart, *flEnableCors, *flDns); err != nil { log.Fatal(err) os.Exit(-1) } @@ -100,7 +101,7 @@ func removePidFile(pidfile string) { } } -func daemon(pidfile string, protoAddrs []string, autoRestart, enableCors bool, flDns string) error { +func daemon(pidfile string, flGraphPath string, protoAddrs []string, autoRestart, enableCors bool, flDns string) error { if err := createPidFile(pidfile); err != nil { log.Fatal(err) } @@ -118,7 +119,7 @@ func daemon(pidfile string, protoAddrs []string, autoRestart, enableCors bool, f if flDns != "" { dns = []string{flDns} } - server, err := docker.NewServer(autoRestart, enableCors, dns) + server, err := docker.NewServer(flGraphPath, autoRestart, enableCors, dns) if err != nil { return err } diff --git a/runtime.go b/runtime.go index c37e292d22..29f5067931 100644 --- a/runtime.go +++ b/runtime.go @@ -246,8 +246,8 @@ func (runtime *Runtime) UpdateCapabilities(quiet bool) { } // FIXME: harmonize with NewGraph() -func NewRuntime(autoRestart bool, dns []string) (*Runtime, error) { - runtime, err := NewRuntimeFromDirectory("/var/lib/docker", autoRestart) +func NewRuntime(flGraphPath string, autoRestart bool, dns []string) (*Runtime, error) { + runtime, err := NewRuntimeFromDirectory(flGraphPath, autoRestart) if err != nil { return nil, err } diff --git a/server.go b/server.go index 35388d8605..992c5da4c9 100644 --- a/server.go +++ b/server.go @@ -1048,11 +1048,11 @@ func (srv *Server) ImageInspect(name string) (*Image, error) { return nil, fmt.Errorf("No such image: %s", name) } -func NewServer(autoRestart, enableCors bool, dns ListOpts) (*Server, error) { +func NewServer(flGraphPath string, autoRestart, enableCors bool, dns ListOpts) (*Server, error) { if runtime.GOARCH != "amd64" { log.Fatalf("The docker runtime currently only supports amd64 (not %s). This will change in the future. Aborting.", runtime.GOARCH) } - runtime, err := NewRuntime(autoRestart, dns) + runtime, err := NewRuntime(flGraphPath, autoRestart, dns) if err != nil { return nil, err }