config.go 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package container // import "github.com/docker/docker/api/types/container"
  2. import (
  3. "io"
  4. "time"
  5. "github.com/docker/docker/api/types/strslice"
  6. "github.com/docker/go-connections/nat"
  7. dockerspec "github.com/moby/docker-image-spec/specs-go/v1"
  8. )
  9. // MinimumDuration puts a minimum on user configured duration.
  10. // This is to prevent API error on time unit. For example, API may
  11. // set 3 as healthcheck interval with intention of 3 seconds, but
  12. // Docker interprets it as 3 nanoseconds.
  13. const MinimumDuration = 1 * time.Millisecond
  14. // StopOptions holds the options to stop or restart a container.
  15. type StopOptions struct {
  16. // Signal (optional) is the signal to send to the container to (gracefully)
  17. // stop it before forcibly terminating the container with SIGKILL after the
  18. // timeout expires. If not value is set, the default (SIGTERM) is used.
  19. Signal string `json:",omitempty"`
  20. // Timeout (optional) is the timeout (in seconds) to wait for the container
  21. // to stop gracefully before forcibly terminating it with SIGKILL.
  22. //
  23. // - Use nil to use the default timeout (10 seconds).
  24. // - Use '-1' to wait indefinitely.
  25. // - Use '0' to not wait for the container to exit gracefully, and
  26. // immediately proceeds to forcibly terminating the container.
  27. // - Other positive values are used as timeout (in seconds).
  28. Timeout *int `json:",omitempty"`
  29. }
  30. // HealthConfig holds configuration settings for the HEALTHCHECK feature.
  31. type HealthConfig = dockerspec.HealthcheckConfig
  32. // ExecStartOptions holds the options to start container's exec.
  33. type ExecStartOptions struct {
  34. Stdin io.Reader
  35. Stdout io.Writer
  36. Stderr io.Writer
  37. ConsoleSize *[2]uint `json:",omitempty"`
  38. }
  39. // Config contains the configuration data about a container.
  40. // It should hold only portable information about the container.
  41. // Here, "portable" means "independent from the host we are running on".
  42. // Non-portable information *should* appear in HostConfig.
  43. // All fields added to this struct must be marked `omitempty` to keep getting
  44. // predictable hashes from the old `v1Compatibility` configuration.
  45. type Config struct {
  46. Hostname string // Hostname
  47. Domainname string // Domainname
  48. User string // User that will run the command(s) inside the container, also support user:group
  49. AttachStdin bool // Attach the standard input, makes possible user interaction
  50. AttachStdout bool // Attach the standard output
  51. AttachStderr bool // Attach the standard error
  52. ExposedPorts nat.PortSet `json:",omitempty"` // List of exposed ports
  53. Tty bool // Attach standard streams to a tty, including stdin if it is not closed.
  54. OpenStdin bool // Open stdin
  55. StdinOnce bool // If true, close stdin after the 1 attached client disconnects.
  56. Env []string // List of environment variable to set in the container
  57. Cmd strslice.StrSlice // Command to run when starting the container
  58. Healthcheck *HealthConfig `json:",omitempty"` // Healthcheck describes how to check the container is healthy
  59. ArgsEscaped bool `json:",omitempty"` // True if command is already escaped (meaning treat as a command line) (Windows specific).
  60. Image string // Name of the image as it was passed by the operator (e.g. could be symbolic)
  61. Volumes map[string]struct{} // List of volumes (mounts) used for the container
  62. WorkingDir string // Current directory (PWD) in the command will be launched
  63. Entrypoint strslice.StrSlice // Entrypoint to run when starting the container
  64. NetworkDisabled bool `json:",omitempty"` // Is network disabled
  65. // Mac Address of the container.
  66. //
  67. // Deprecated: this field is deprecated since API v1.44. Use EndpointSettings.MacAddress instead.
  68. MacAddress string `json:",omitempty"`
  69. OnBuild []string // ONBUILD metadata that were defined on the image Dockerfile
  70. Labels map[string]string // List of labels set to this container
  71. StopSignal string `json:",omitempty"` // Signal to stop a container
  72. StopTimeout *int `json:",omitempty"` // Timeout (in seconds) to stop a container
  73. Shell strslice.StrSlice `json:",omitempty"` // Shell for shell-form of RUN, CMD, ENTRYPOINT
  74. }