diff --git a/image_recover_tool/image-check/daemon/app/main.go b/image_recover_tool/image-check/daemon/app/main.go index 1fb8ba64f8970ca911beda9401c199cd9df5ba3e..f5b0fc1b1cb47fece6c2b65e218044ba399592d6 100644 --- a/image_recover_tool/image-check/daemon/app/main.go +++ b/image_recover_tool/image-check/daemon/app/main.go @@ -58,6 +58,10 @@ docker image check tool Name: "root", Usage: "root directory for docker", }, + cli.StringFlag{ + Name: "storage-isolate", + Usage: "docker storage-isolate path", + }, } app.Commands = append([]cli.Command{ images.Command, diff --git a/image_recover_tool/image-check/daemon/commands/commands.go b/image_recover_tool/image-check/daemon/commands/commands.go index 963ba5b92423cf2f75bb00b30d6d3db051165d8a..937989a564b1ae3203f4b0ec587e7ec2eadbdc91 100644 --- a/image_recover_tool/image-check/daemon/commands/commands.go +++ b/image_recover_tool/image-check/daemon/commands/commands.go @@ -23,7 +23,7 @@ func NewDaemon(context *cli.Context) (*Daemon, error) { var err error logrus.Info("Start check tool") - d.daemonConfigFile, err = config.GetDockerRoot(context.GlobalString("config"), context.GlobalString("root"), context.GlobalString("driver")) + d.daemonConfigFile, err = config.GetDockerRoot(context.GlobalString("config"), context.GlobalString("root"), context.GlobalString("driver"),context.GlobalString("storage-isolate")) if err != nil { logrus.Errorf("Failed to get the dockerd configuration file: %v", err) return nil, err diff --git a/image_recover_tool/image-check/daemon/config/config.go b/image_recover_tool/image-check/daemon/config/config.go index e1ab0094505264966f00e078592bdb70379d4f53..6e18fa81acbeac14025ffd7fe0e131d7a2bb0f14 100644 --- a/image_recover_tool/image-check/daemon/config/config.go +++ b/image_recover_tool/image-check/daemon/config/config.go @@ -19,12 +19,12 @@ const ( ) type DaemonConfig struct { - Root string `json:"graph,omitempty"` - GraphDriver string `json:"storage-driver,omitempty"` + Root string `json:"graph,omitempty"` + GraphDriver string `json:"storage-driver,omitempty"` StorageIsolate string `json:"storage-isolate,omitempty"` } -func GetDockerRoot(dockerdConfigPath, root, driver string) (*DaemonConfig, error) { +func GetDockerRoot(dockerdConfigPath, root, driver string, storageIsolate string) (*DaemonConfig, error) { dc := &DaemonConfig{} exist, err := dc.checkConfigurationIsExist(dockerdConfigPath) @@ -39,17 +39,13 @@ func GetDockerRoot(dockerdConfigPath, root, driver string) (*DaemonConfig, error } if fileConfig.Root != "" { dc.Root = fileConfig.Root - dc.StorageIsolate = fileConfig.Root - }else { - dc.StorageIsolate = DefaultPath } if fileConfig.GraphDriver != "" { dc.GraphDriver = fileConfig.GraphDriver } - if fileConfig.StorageIsolate != ""{ + if fileConfig.StorageIsolate != "" { dc.StorageIsolate = fileConfig.StorageIsolate } - } else { logrus.Warnf("The docker configuration file not found: %s", dockerdConfigPath) } @@ -60,7 +56,17 @@ func GetDockerRoot(dockerdConfigPath, root, driver string) (*DaemonConfig, error if driver != "" { dc.GraphDriver = driver } - + if storageIsolate != "" { + dc.StorageIsolate = storageIsolate + }else { + if dc.StorageIsolate == ""{ + if dc.Root !=""{ + dc.StorageIsolate = dc.Root + }else { + dc.StorageIsolate = DefaultPath + } + } + } if dc.Root == "" { dc.Root = DefaultPath }