瀏覽代碼

add a -mount-method flag

Victor Vieux 11 年之前
父節點
當前提交
c1e25d7273
共有 4 個文件被更改,包括 19 次插入10 次删除
  1. 4 3
      docker/docker.go
  2. 11 3
      runtime.go
  3. 2 2
      runtime_test.go
  4. 2 2
      server.go

+ 4 - 3
docker/docker.go

@@ -36,6 +36,7 @@ func main() {
 	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")
+	flMountMethod := flag.String("mount-method", "", "Set the mount method to use, default is auto. [aufs, devicemapper, filesystem]")
 	flHosts := docker.ListOpts{fmt.Sprintf("unix://%s", docker.DEFAULTUNIXSOCKET)}
 	flag.Var(&flHosts, "H", "tcp://host:port to bind/connect to or unix://path/to/socket to use")
 	flag.Parse()
@@ -65,7 +66,7 @@ func main() {
 			flag.Usage()
 			return
 		}
-		if err := daemon(*pidfile, *flGraphPath, flHosts, *flAutoRestart, *flEnableCors, *flDns); err != nil {
+		if err := daemon(*pidfile, *flGraphPath, flHosts, *flAutoRestart, *flEnableCors, *flDns, *flMountMethod); err != nil {
 			log.Fatal(err)
 			os.Exit(-1)
 		}
@@ -116,7 +117,7 @@ func removePidFile(pidfile string) {
 	}
 }
 
-func daemon(pidfile string, flGraphPath string, protoAddrs []string, autoRestart, enableCors bool, flDns string) error {
+func daemon(pidfile string, flGraphPath string, protoAddrs []string, autoRestart, enableCors bool, flDns, mountMethod  string) error {
 	if err := createPidFile(pidfile); err != nil {
 		log.Fatal(err)
 	}
@@ -134,7 +135,7 @@ func daemon(pidfile string, flGraphPath string, protoAddrs []string, autoRestart
 	if flDns != "" {
 		dns = []string{flDns}
 	}
-	server, err := docker.NewServer(flGraphPath, devmapper.NewDeviceSetDM(flGraphPath), autoRestart, enableCors, dns)
+	server, err := docker.NewServer(flGraphPath, devmapper.NewDeviceSetDM(flGraphPath), autoRestart, enableCors, dns, mountMethod)
 	if err != nil {
 		return err
 	}

+ 11 - 3
runtime.go

@@ -518,8 +518,8 @@ func (runtime *Runtime) Commit(container *Container, repository, tag, comment, a
 }
 
 // FIXME: harmonize with NewGraph()
-func NewRuntime(flGraphPath string, deviceSet DeviceSet, autoRestart bool, dns []string) (*Runtime, error) {
-	runtime, err := NewRuntimeFromDirectory(flGraphPath, deviceSet, autoRestart)
+func NewRuntime(flGraphPath string, deviceSet DeviceSet, autoRestart bool, dns []string, mountMethod string) (*Runtime, error) {
+	runtime, err := NewRuntimeFromDirectory(flGraphPath, deviceSet, autoRestart, mountMethod)
 	if err != nil {
 		return nil, err
 	}
@@ -537,7 +537,7 @@ func NewRuntime(flGraphPath string, deviceSet DeviceSet, autoRestart bool, dns [
 	return runtime, nil
 }
 
-func NewRuntimeFromDirectory(root string, deviceSet DeviceSet, autoRestart bool) (*Runtime, error) {
+func NewRuntimeFromDirectory(root string, deviceSet DeviceSet, autoRestart bool, mountMethod string) (*Runtime, error) {
 	runtimeRepo := path.Join(root, "containers")
 
 	if err := os.MkdirAll(runtimeRepo, 0700); err != nil && !os.IsExist(err) {
@@ -577,6 +577,14 @@ func NewRuntimeFromDirectory(root string, deviceSet DeviceSet, autoRestart bool)
 		deviceSet:      deviceSet,
 	}
 
+	if mountMethod == "aufs" {
+		runtime.mountMethod = MountMethodAUFS
+	} else if mountMethod == "devicemapper" {
+		runtime.mountMethod = MountMethodDeviceMapper
+	} else if mountMethod == "filesystem" {
+		runtime.mountMethod = MountMethodFilesystem
+	}
+
 	if err := runtime.restore(); err != nil {
 		return nil, err
 	}

+ 2 - 2
runtime_test.go

@@ -135,7 +135,7 @@ func init() {
 	}
 
 	// Make it our Store root
-	if runtime, err := NewRuntimeFromDirectory(unitTestStoreBase, devmapper.NewDeviceSetDM(unitTestStoreDevicesBase), false); err != nil {
+	if runtime, err := NewRuntimeFromDirectory(unitTestStoreBase, devmapper.NewDeviceSetDM(unitTestStoreDevicesBase), false, ""); err != nil {
 		panic(err)
 	} else {
 		globalRuntime = runtime
@@ -504,7 +504,7 @@ func TestRestore(t *testing.T) {
 
 	// Here are are simulating a docker restart - that is, reloading all containers
 	// from scratch
-	runtime2, err := NewRuntimeFromDirectory(runtime1.root, runtime1.deviceSet, false)
+	runtime2, err := NewRuntimeFromDirectory(runtime1.root, runtime1.deviceSet, false, "")
 	if err != nil {
 		t.Fatal(err)
 	}

+ 2 - 2
server.go

@@ -1294,11 +1294,11 @@ func (srv *Server) ContainerCopy(name string, resource string, out io.Writer) er
 
 }
 
-func NewServer(flGraphPath string, deviceSet DeviceSet, autoRestart, enableCors bool, dns ListOpts) (*Server, error) {
+func NewServer(flGraphPath string, deviceSet DeviceSet, autoRestart, enableCors bool, dns ListOpts, mountMethod string) (*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(flGraphPath, deviceSet, autoRestart, dns)
+	runtime, err := NewRuntime(flGraphPath, deviceSet, autoRestart, dns, mountMethod)
 	if err != nil {
 		return nil, err
 	}