container.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package swarm // import "github.com/docker/docker/api/types/swarm"
  2. import (
  3. "time"
  4. "github.com/docker/docker/api/types/container"
  5. "github.com/docker/docker/api/types/mount"
  6. "github.com/docker/go-units"
  7. )
  8. // DNSConfig specifies DNS related configurations in resolver configuration file (resolv.conf)
  9. // Detailed documentation is available in:
  10. // http://man7.org/linux/man-pages/man5/resolv.conf.5.html
  11. // `nameserver`, `search`, `options` have been supported.
  12. // TODO: `domain` is not supported yet.
  13. type DNSConfig struct {
  14. // Nameservers specifies the IP addresses of the name servers
  15. Nameservers []string `json:",omitempty"`
  16. // Search specifies the search list for host-name lookup
  17. Search []string `json:",omitempty"`
  18. // Options allows certain internal resolver variables to be modified
  19. Options []string `json:",omitempty"`
  20. }
  21. // SELinuxContext contains the SELinux labels of the container.
  22. type SELinuxContext struct {
  23. Disable bool
  24. User string
  25. Role string
  26. Type string
  27. Level string
  28. }
  29. // SeccompMode is the type used for the enumeration of possible seccomp modes
  30. // in SeccompOpts
  31. type SeccompMode string
  32. const (
  33. SeccompModeDefault SeccompMode = "default"
  34. SeccompModeUnconfined SeccompMode = "unconfined"
  35. SeccompModeCustom SeccompMode = "custom"
  36. )
  37. // SeccompOpts defines the options for configuring seccomp on a swarm-managed
  38. // container.
  39. type SeccompOpts struct {
  40. // Mode is the SeccompMode used for the container.
  41. Mode SeccompMode `json:",omitempty"`
  42. // Profile is the custom seccomp profile as a json object to be used with
  43. // the container. Mode should be set to SeccompModeCustom when using a
  44. // custom profile in this manner.
  45. Profile []byte `json:",omitempty"`
  46. }
  47. // AppArmorMode is type used for the enumeration of possible AppArmor modes in
  48. // AppArmorOpts
  49. type AppArmorMode string
  50. const (
  51. AppArmorModeDefault AppArmorMode = "default"
  52. AppArmorModeDisabled AppArmorMode = "disabled"
  53. )
  54. // AppArmorOpts defines the options for configuring AppArmor on a swarm-managed
  55. // container. Currently, custom AppArmor profiles are not supported.
  56. type AppArmorOpts struct {
  57. Mode AppArmorMode `json:",omitempty"`
  58. }
  59. // CredentialSpec for managed service account (Windows only)
  60. type CredentialSpec struct {
  61. Config string
  62. File string
  63. Registry string
  64. }
  65. // Privileges defines the security options for the container.
  66. type Privileges struct {
  67. CredentialSpec *CredentialSpec
  68. SELinuxContext *SELinuxContext
  69. Seccomp *SeccompOpts `json:",omitempty"`
  70. AppArmor *AppArmorOpts `json:",omitempty"`
  71. NoNewPrivileges bool
  72. }
  73. // ContainerSpec represents the spec of a container.
  74. type ContainerSpec struct {
  75. Image string `json:",omitempty"`
  76. Labels map[string]string `json:",omitempty"`
  77. Command []string `json:",omitempty"`
  78. Args []string `json:",omitempty"`
  79. Hostname string `json:",omitempty"`
  80. Env []string `json:",omitempty"`
  81. Dir string `json:",omitempty"`
  82. User string `json:",omitempty"`
  83. Groups []string `json:",omitempty"`
  84. Privileges *Privileges `json:",omitempty"`
  85. Init *bool `json:",omitempty"`
  86. StopSignal string `json:",omitempty"`
  87. TTY bool `json:",omitempty"`
  88. OpenStdin bool `json:",omitempty"`
  89. ReadOnly bool `json:",omitempty"`
  90. Mounts []mount.Mount `json:",omitempty"`
  91. StopGracePeriod *time.Duration `json:",omitempty"`
  92. Healthcheck *container.HealthConfig `json:",omitempty"`
  93. // The format of extra hosts on swarmkit is specified in:
  94. // http://man7.org/linux/man-pages/man5/hosts.5.html
  95. // IP_address canonical_hostname [aliases...]
  96. Hosts []string `json:",omitempty"`
  97. DNSConfig *DNSConfig `json:",omitempty"`
  98. Secrets []*SecretReference `json:",omitempty"`
  99. Configs []*ConfigReference `json:",omitempty"`
  100. Isolation container.Isolation `json:",omitempty"`
  101. Sysctls map[string]string `json:",omitempty"`
  102. CapabilityAdd []string `json:",omitempty"`
  103. CapabilityDrop []string `json:",omitempty"`
  104. Ulimits []*units.Ulimit `json:",omitempty"`
  105. }