reload_unix.go 1.4 KB

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