config.go 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. // Retries is the number of consecutive failures needed to consider a container as unhealthy.
  21. // Zero means inherit.
  22. Retries int `json:",omitempty"`
  23. }
  24. // Config contains the configuration data about a container.
  25. // It should hold only portable information about the container.
  26. // Here, "portable" means "independent from the host we are running on".
  27. // Non-portable information *should* appear in HostConfig.
  28. // All fields added to this struct must be marked `omitempty` to keep getting
  29. // predictable hashes from the old `v1Compatibility` configuration.
  30. type Config struct {
  31. Hostname string // Hostname
  32. Domainname string // Domainname
  33. User string // User that will run the command(s) inside the container, also support user:group
  34. AttachStdin bool // Attach the standard input, makes possible user interaction
  35. AttachStdout bool // Attach the standard output
  36. AttachStderr bool // Attach the standard error
  37. ExposedPorts map[nat.Port]struct{} `json:",omitempty"` // List of exposed ports
  38. Tty bool // Attach standard streams to a tty, including stdin if it is not closed.
  39. OpenStdin bool // Open stdin
  40. StdinOnce bool // If true, close stdin after the 1 attached client disconnects.
  41. Env []string // List of environment variable to set in the container
  42. Cmd strslice.StrSlice // Command to run when starting the container
  43. Healthcheck *HealthConfig `json:",omitempty"` // Healthcheck describes how to check the container is healthy
  44. ArgsEscaped bool `json:",omitempty"` // True if command is already escaped (Windows specific)
  45. Image string // Name of the image as it was passed by the operator (e.g. could be symbolic)
  46. Volumes map[string]struct{} // List of volumes (mounts) used for the container
  47. WorkingDir string // Current directory (PWD) in the command will be launched
  48. Entrypoint strslice.StrSlice // Entrypoint to run when starting the container
  49. NetworkDisabled bool `json:",omitempty"` // Is network disabled
  50. MacAddress string `json:",omitempty"` // Mac Address of the container
  51. OnBuild []string // ONBUILD metadata that were defined on the image Dockerfile
  52. Labels map[string]string // List of labels set to this container
  53. StopSignal string `json:",omitempty"` // Signal to stop a container
  54. StopTimeout *int `json:",omitempty"` // Timeout (in seconds) to stop a container
  55. Shell strslice.StrSlice `json:",omitempty"` // Shell for shell-form of RUN, CMD, ENTRYPOINT
  56. }