diff --git a/cmd/dockerd/daemon_windows.go b/cmd/dockerd/daemon_windows.go index a04c42eac2..8c1ff01319 100644 --- a/cmd/dockerd/daemon_windows.go +++ b/cmd/dockerd/daemon_windows.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "os" + "path/filepath" "time" "github.com/containerd/log" @@ -23,8 +24,14 @@ func getDefaultDaemonConfigFile() string { } // setPlatformOptions applies platform-specific CLI configuration options. -// There is none on windows, so this is a no-op. func setPlatformOptions(conf *config.Config) error { + if conf.Pidfile == "" { + // On Windows, the pid-file location is relative to the daemon's data-root, + // which is configurable, so we cannot use a fixed default location. + // Instead, we set the location here, after we parsed command-line flags + // and loaded the configuration file (if any). + conf.Pidfile = filepath.Join(conf.Root, "docker.pid") + } return nil } diff --git a/cmd/dockerd/docker_windows.go b/cmd/dockerd/docker_windows.go index fb37dec74c..158490c3f5 100644 --- a/cmd/dockerd/docker_windows.go +++ b/cmd/dockerd/docker_windows.go @@ -4,17 +4,12 @@ import ( "fmt" "io" "os" - "path/filepath" "github.com/Microsoft/go-winio/pkg/etwlogrus" "github.com/containerd/log" ) func runDaemon(opts *daemonOptions) error { - // Windows specific settings as these are not defaulted. - if opts.daemonConfig.Pidfile == "" { - opts.daemonConfig.Pidfile = filepath.Join(opts.daemonConfig.Root, "docker.pid") - } cli, err := NewDaemonCli(opts) if err != nil { return err