config.go 3.7 KB

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