config_common_unix.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // +build solaris linux freebsd
  2. package config
  3. import (
  4. "net"
  5. "github.com/docker/docker/api/types"
  6. )
  7. // CommonUnixConfig defines configuration of a docker daemon that is
  8. // common across Unix platforms.
  9. type CommonUnixConfig struct {
  10. ExecRoot string `json:"exec-root,omitempty"`
  11. ContainerdAddr string `json:"containerd,omitempty"`
  12. Runtimes map[string]types.Runtime `json:"runtimes,omitempty"`
  13. DefaultRuntime string `json:"default-runtime,omitempty"`
  14. DefaultInitBinary string `json:"default-init,omitempty"`
  15. }
  16. type commonUnixBridgeConfig struct {
  17. DefaultIP net.IP `json:"ip,omitempty"`
  18. IP string `json:"bip,omitempty"`
  19. DefaultGatewayIPv4 net.IP `json:"default-gateway,omitempty"`
  20. DefaultGatewayIPv6 net.IP `json:"default-gateway-v6,omitempty"`
  21. InterContainerCommunication bool `json:"icc,omitempty"`
  22. }
  23. // GetRuntime returns the runtime path and arguments for a given
  24. // runtime name
  25. func (conf *Config) GetRuntime(name string) *types.Runtime {
  26. conf.Lock()
  27. defer conf.Unlock()
  28. if rt, ok := conf.Runtimes[name]; ok {
  29. return &rt
  30. }
  31. return nil
  32. }
  33. // GetDefaultRuntimeName returns the current default runtime
  34. func (conf *Config) GetDefaultRuntimeName() string {
  35. conf.Lock()
  36. rt := conf.DefaultRuntime
  37. conf.Unlock()
  38. return rt
  39. }
  40. // GetAllRuntimes returns a copy of the runtimes map
  41. func (conf *Config) GetAllRuntimes() map[string]types.Runtime {
  42. conf.Lock()
  43. rts := conf.Runtimes
  44. conf.Unlock()
  45. return rts
  46. }
  47. // GetExecRoot returns the user configured Exec-root
  48. func (conf *Config) GetExecRoot() string {
  49. return conf.ExecRoot
  50. }
  51. // GetInitPath returns the configure docker-init path
  52. func (conf *Config) GetInitPath() string {
  53. conf.Lock()
  54. defer conf.Unlock()
  55. if conf.InitPath != "" {
  56. return conf.InitPath
  57. }
  58. if conf.DefaultInitBinary != "" {
  59. return conf.DefaultInitBinary
  60. }
  61. return DefaultInitBinary
  62. }