mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
add a -mount-method flag
This commit is contained in:
parent
0484b2c325
commit
aeb89ffbba
4 changed files with 19 additions and 10 deletions
|
@ -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
|
||||
}
|
||||
|
|
14
runtime.go
14
runtime.go
|
@ -519,8 +519,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
|
||||
}
|
||||
|
@ -538,7 +538,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) {
|
||||
|
@ -578,6 +578,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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -1299,11 +1299,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
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue