config_common_unix.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // +build 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. Runtimes map[string]types.Runtime `json:"runtimes,omitempty"`
  11. DefaultRuntime string `json:"default-runtime,omitempty"`
  12. DefaultInitBinary string `json:"default-init,omitempty"`
  13. }
  14. type commonUnixBridgeConfig struct {
  15. DefaultIP net.IP `json:"ip,omitempty"`
  16. IP string `json:"bip,omitempty"`
  17. DefaultGatewayIPv4 net.IP `json:"default-gateway,omitempty"`
  18. DefaultGatewayIPv6 net.IP `json:"default-gateway-v6,omitempty"`
  19. InterContainerCommunication bool `json:"icc,omitempty"`
  20. }
  21. // GetRuntime returns the runtime path and arguments for a given
  22. // runtime name
  23. func (conf *Config) GetRuntime(name string) *types.Runtime {
  24. conf.Lock()
  25. defer conf.Unlock()
  26. if rt, ok := conf.Runtimes[name]; ok {
  27. return &rt
  28. }
  29. return nil
  30. }
  31. // GetDefaultRuntimeName returns the current default runtime
  32. func (conf *Config) GetDefaultRuntimeName() string {
  33. conf.Lock()
  34. rt := conf.DefaultRuntime
  35. conf.Unlock()
  36. return rt
  37. }
  38. // GetAllRuntimes returns a copy of the runtimes map
  39. func (conf *Config) GetAllRuntimes() map[string]types.Runtime {
  40. conf.Lock()
  41. rts := conf.Runtimes
  42. conf.Unlock()
  43. return rts
  44. }
  45. // GetExecRoot returns the user configured Exec-root
  46. func (conf *Config) GetExecRoot() string {
  47. return conf.ExecRoot
  48. }
  49. // GetInitPath returns the configured docker-init path
  50. func (conf *Config) GetInitPath() string {
  51. conf.Lock()
  52. defer conf.Unlock()
  53. if conf.InitPath != "" {
  54. return conf.InitPath
  55. }
  56. if conf.DefaultInitBinary != "" {
  57. return conf.DefaultInitBinary
  58. }
  59. return DefaultInitBinary
  60. }