config.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package container // import "github.com/docker/docker/api/types/container"
  2. import (
  3. "time"
  4. "github.com/docker/docker/api/types/strslice"
  5. "github.com/docker/go-connections/nat"
  6. )
  7. // MinimumDuration puts a minimum on user configured duration.
  8. // This is to prevent API error on time unit. For example, API may
  9. // set 3 as healthcheck interval with intention of 3 seconds, but
  10. // Docker interprets it as 3 nanoseconds.
  11. const MinimumDuration = 1 * time.Millisecond
  12. // HealthConfig holds configuration settings for the HEALTHCHECK feature.
  13. type HealthConfig struct {
  14. // Test is the test to perform to check that the container is healthy.
  15. // An empty slice means to inherit the default.
  16. // The options are:
  17. // {} : inherit healthcheck
  18. // {"NONE"} : disable healthcheck
  19. // {"CMD", args...} : exec arguments directly
  20. // {"CMD-SHELL", command} : run command with system's default shell
  21. Test []string `json:",omitempty"`
  22. // Zero means to inherit. Durations are expressed as integer nanoseconds.
  23. Interval time.Duration `json:",omitempty"` // Interval is the time to wait between checks.
  24. Timeout time.Duration `json:",omitempty"` // Timeout is the time to wait before considering the check to have hung.
  25. StartPeriod time.Duration `json:",omitempty"` // The start period for the container to initialize before the retries starts to count down.
  26. // Retries is the number of consecutive failures needed to consider a container as unhealthy.
  27. // Zero means inherit.
  28. Retries int `json:",omitempty"`
  29. }
  30. // Config contains the configuration data about a container.
  31. // It should hold only portable information about the container.
  32. // Here, "portable" means "independent from the host we are running on".
  33. // Non-portable information *should* appear in HostConfig.
  34. // All fields added to this struct must be marked `omitempty` to keep getting
  35. // predictable hashes from the old `v1Compatibility` configuration.
  36. type Config struct {
  37. Hostname string // Hostname
  38. Domainname string // Domainname
  39. User string // User that will run the command(s) inside the container, also support user:group
  40. AttachStdin bool // Attach the standard input, makes possible user interaction
  41. AttachStdout bool // Attach the standard output
  42. AttachStderr bool // Attach the standard error
  43. ExposedPorts nat.PortSet `json:",omitempty"` // List of exposed ports
  44. Tty bool // Attach standard streams to a tty, including stdin if it is not closed.
  45. OpenStdin bool // Open stdin
  46. StdinOnce bool // If true, close stdin after the 1 attached client disconnects.
  47. Env []string // List of environment variable to set in the container
  48. Cmd strslice.StrSlice // Command to run when starting the container
  49. Healthcheck *HealthConfig `json:",omitempty"` // Healthcheck describes how to check the container is healthy
  50. ArgsEscaped bool `json:",omitempty"` // True if command is already escaped (meaning treat as a command line) (Windows specific).
  51. Image string // Name of the image as it was passed by the operator (e.g. could be symbolic)
  52. Volumes map[string]struct{} // List of volumes (mounts) used for the container
  53. WorkingDir string // Current directory (PWD) in the command will be launched
  54. Entrypoint strslice.StrSlice // Entrypoint to run when starting the container
  55. NetworkDisabled bool `json:",omitempty"` // Is network disabled
  56. MacAddress string `json:",omitempty"` // Mac Address of the container
  57. OnBuild []string // ONBUILD metadata that were defined on the image Dockerfile
  58. Labels map[string]string // List of labels set to this container
  59. StopSignal string `json:",omitempty"` // Signal to stop a container
  60. StopTimeout *int `json:",omitempty"` // Timeout (in seconds) to stop a container
  61. Shell strslice.StrSlice `json:",omitempty"` // Shell for shell-form of RUN, CMD, ENTRYPOINT
  62. }