github.com/moby/docker@v26.1.3+incompatible/api/types/container/config.go (about)

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