reload_unix.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //go:build linux || freebsd
  2. package daemon // import "github.com/docker/docker/daemon"
  3. import (
  4. "bytes"
  5. "strconv"
  6. "github.com/docker/docker/daemon/config"
  7. )
  8. // reloadPlatform updates configuration with platform specific options
  9. // and updates the passed attributes
  10. func (daemon *Daemon) reloadPlatform(txn *reloadTxn, newCfg *configStore, conf *config.Config, attributes map[string]string) error {
  11. if conf.DefaultRuntime != "" {
  12. newCfg.DefaultRuntime = conf.DefaultRuntime
  13. }
  14. if conf.IsValueSet("runtimes") {
  15. newCfg.Config.Runtimes = conf.Runtimes
  16. }
  17. var err error
  18. newCfg.Runtimes, err = setupRuntimes(&newCfg.Config)
  19. if err != nil {
  20. return err
  21. }
  22. if conf.IsValueSet("default-shm-size") {
  23. newCfg.ShmSize = conf.ShmSize
  24. }
  25. if conf.CgroupNamespaceMode != "" {
  26. newCfg.CgroupNamespaceMode = conf.CgroupNamespaceMode
  27. }
  28. if conf.IpcMode != "" {
  29. newCfg.IpcMode = conf.IpcMode
  30. }
  31. // Update attributes
  32. var runtimeList bytes.Buffer
  33. for name, rt := range newCfg.Config.Runtimes {
  34. if runtimeList.Len() > 0 {
  35. runtimeList.WriteRune(' ')
  36. }
  37. runtimeList.WriteString(name + ":" + rt.Path)
  38. }
  39. attributes["runtimes"] = runtimeList.String()
  40. attributes["default-runtime"] = newCfg.DefaultRuntime
  41. attributes["default-shm-size"] = strconv.FormatInt(int64(newCfg.ShmSize), 10)
  42. attributes["default-ipc-mode"] = newCfg.IpcMode
  43. attributes["default-cgroupns-mode"] = newCfg.CgroupNamespaceMode
  44. return nil
  45. }