Browse code

Add argument to allow setting base directory for docker daemon's storage to values other than "/var/lib/docker".

Eric Myhre authored on 2013/06/21 06:29:54
Showing 3 changed files
... ...
@@ -30,6 +30,7 @@ func main() {
30 30
 	flAutoRestart := flag.Bool("r", false, "Restart previously running containers")
31 31
 	bridgeName := flag.String("b", "", "Attach containers to a pre-existing network bridge")
32 32
 	pidfile := flag.String("p", "/var/run/docker.pid", "File containing process PID")
33
+	flGraphPath := flag.String("g", "/var/lib/docker", "Path to graph storage base dir.")
33 34
 	flEnableCors := flag.Bool("api-enable-cors", false, "Enable CORS requests in the remote api.")
34 35
 	flDns := flag.String("dns", "", "Set custom dns servers")
35 36
 	flHosts := docker.ListOpts{fmt.Sprintf("tcp://%s:%d", docker.DEFAULTHTTPHOST, docker.DEFAULTHTTPPORT)}
... ...
@@ -56,7 +57,7 @@ func main() {
56 56
 			flag.Usage()
57 57
 			return
58 58
 		}
59
-		if err := daemon(*pidfile, flHosts, *flAutoRestart, *flEnableCors, *flDns); err != nil {
59
+		if err := daemon(*pidfile, *flGraphPath, flHosts, *flAutoRestart, *flEnableCors, *flDns); err != nil {
60 60
 			log.Fatal(err)
61 61
 			os.Exit(-1)
62 62
 		}
... ...
@@ -100,7 +101,7 @@ func removePidFile(pidfile string) {
100 100
 	}
101 101
 }
102 102
 
103
-func daemon(pidfile string, protoAddrs []string, autoRestart, enableCors bool, flDns string) error {
103
+func daemon(pidfile string, flGraphPath string, protoAddrs []string, autoRestart, enableCors bool, flDns string) error {
104 104
 	if err := createPidFile(pidfile); err != nil {
105 105
 		log.Fatal(err)
106 106
 	}
... ...
@@ -118,7 +119,7 @@ func daemon(pidfile string, protoAddrs []string, autoRestart, enableCors bool, f
118 118
 	if flDns != "" {
119 119
 		dns = []string{flDns}
120 120
 	}
121
-	server, err := docker.NewServer(autoRestart, enableCors, dns)
121
+	server, err := docker.NewServer(flGraphPath, autoRestart, enableCors, dns)
122 122
 	if err != nil {
123 123
 		return err
124 124
 	}
... ...
@@ -246,8 +246,8 @@ func (runtime *Runtime) UpdateCapabilities(quiet bool) {
246 246
 }
247 247
 
248 248
 // FIXME: harmonize with NewGraph()
249
-func NewRuntime(autoRestart bool, dns []string) (*Runtime, error) {
250
-	runtime, err := NewRuntimeFromDirectory("/var/lib/docker", autoRestart)
249
+func NewRuntime(flGraphPath string, autoRestart bool, dns []string) (*Runtime, error) {
250
+	runtime, err := NewRuntimeFromDirectory(flGraphPath, autoRestart)
251 251
 	if err != nil {
252 252
 		return nil, err
253 253
 	}
... ...
@@ -1048,11 +1048,11 @@ func (srv *Server) ImageInspect(name string) (*Image, error) {
1048 1048
 	return nil, fmt.Errorf("No such image: %s", name)
1049 1049
 }
1050 1050
 
1051
-func NewServer(autoRestart, enableCors bool, dns ListOpts) (*Server, error) {
1051
+func NewServer(flGraphPath string, autoRestart, enableCors bool, dns ListOpts) (*Server, error) {
1052 1052
 	if runtime.GOARCH != "amd64" {
1053 1053
 		log.Fatalf("The docker runtime currently only supports amd64 (not %s). This will change in the future. Aborting.", runtime.GOARCH)
1054 1054
 	}
1055
-	runtime, err := NewRuntime(autoRestart, dns)
1055
+	runtime, err := NewRuntime(flGraphPath, autoRestart, dns)
1056 1056
 	if err != nil {
1057 1057
 		return nil, err
1058 1058
 	}