github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/api/types/container/config.go (about)

     1  package container
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/docker/docker/api/types/strslice"
     7  	"github.com/docker/go-connections/nat"
     8  )
     9  
    10  // HealthConfig holds configuration settings for the HEALTHCHECK feature.
    11  type HealthConfig struct {
    12  	// Test is the test to perform to check that the container is healthy.
    13  	// An empty slice means to inherit the default.
    14  	// The options are:
    15  	// {} : inherit healthcheck
    16  	// {"NONE"} : disable healthcheck
    17  	// {"CMD", args...} : exec arguments directly
    18  	// {"CMD-SHELL", command} : run command with system's default shell
    19  	Test []string `json:",omitempty"`
    20  
    21  	// Zero means to inherit. Durations are expressed as integer nanoseconds.
    22  	Interval time.Duration `json:",omitempty"` // Interval is the time to wait between checks.
    23  	Timeout  time.Duration `json:",omitempty"` // Timeout is the time to wait before considering the check to have hung.
    24  
    25  	// Retries is the number of consecutive failures needed to consider a container as unhealthy.
    26  	// Zero means inherit.
    27  	Retries int `json:",omitempty"`
    28  }
    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 (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  }