docker_windows.go 905 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package main
  2. import (
  3. "path/filepath"
  4. _ "github.com/docker/docker/autogen/winresources/dockerd"
  5. "github.com/sirupsen/logrus"
  6. )
  7. func runDaemon(opts *daemonOptions) error {
  8. daemonCli := NewDaemonCli()
  9. // On Windows, this may be launching as a service or with an option to
  10. // register the service.
  11. stop, runAsService, err := initService(daemonCli)
  12. if err != nil {
  13. logrus.Fatal(err)
  14. }
  15. if stop {
  16. return nil
  17. }
  18. // Windows specific settings as these are not defaulted.
  19. if opts.configFile == "" {
  20. opts.configFile = filepath.Join(opts.daemonConfig.Root, `config\daemon.json`)
  21. }
  22. if runAsService {
  23. // If Windows SCM manages the service - no need for PID files
  24. opts.daemonConfig.Pidfile = ""
  25. } else if opts.daemonConfig.Pidfile == "" {
  26. opts.daemonConfig.Pidfile = filepath.Join(opts.daemonConfig.Root, "docker.pid")
  27. }
  28. err = daemonCli.start(opts)
  29. notifyShutdown(err)
  30. return err
  31. }