From 37a241768d2ed0f005ca376e76fc9e1e98cafe26 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 9 Aug 2022 22:13:18 +0200 Subject: [PATCH] cmd/dockerd: fix some minor issues in Windows implementation - properly use filepath.Join() for Windows paths - use getDaemonConfDir() to get the path for storing daemon.json - return error instead of logrus.Fatal(). The logrus.Fatal() was a left-over from when Cobra was not used, and appears to have been missed in commit fb83394714a9797f8ca5a08023a89560ce6c4aa3, which did the conversion to Cobra. Signed-off-by: Sebastiaan van Stijn --- cmd/dockerd/daemon_windows.go | 2 +- cmd/dockerd/docker_windows.go | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/dockerd/daemon_windows.go b/cmd/dockerd/daemon_windows.go index 08a77b7cb8..c592e286e3 100644 --- a/cmd/dockerd/daemon_windows.go +++ b/cmd/dockerd/daemon_windows.go @@ -24,7 +24,7 @@ func setDefaultUmask() error { } func getDaemonConfDir(root string) (string, error) { - return filepath.Join(root, `\config`), nil + return filepath.Join(root, "config"), nil } // preNotifyReady sends a message to the host when the API is active, but before the daemon is diff --git a/cmd/dockerd/docker_windows.go b/cmd/dockerd/docker_windows.go index 9295741217..a132bdf285 100644 --- a/cmd/dockerd/docker_windows.go +++ b/cmd/dockerd/docker_windows.go @@ -15,7 +15,7 @@ func runDaemon(opts *daemonOptions) error { // register the service. stop, runAsService, err := initService(daemonCli) if err != nil { - logrus.Fatal(err) + return err } if stop { @@ -24,7 +24,11 @@ func runDaemon(opts *daemonOptions) error { // Windows specific settings as these are not defaulted. if opts.configFile == "" { - opts.configFile = filepath.Join(opts.daemonConfig.Root, `config\daemon.json`) + configDir, err := getDaemonConfDir(opts.daemonConfig.Root) + if err != nil { + return err + } + opts.configFile = filepath.Join(configDir, "daemon.json") } if runAsService { // If Windows SCM manages the service - no need for PID files