{"modulePath":"github.com/docker/compose-cli","version":"v1.0.35","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package containers\n\n## Constants\n\n```go\nconst (\n\t// RestartPolicyNone Never restarts\n\tRestartPolicyNone = \"none\"\n\t// RestartPolicyAny Always restarts\n\tRestartPolicyAny = \"any\"\n\t// RestartPolicyOnFailure Restarts only on failure\n\tRestartPolicyOnFailure = \"on-failure\"\n\n\t// RestartPolicyRunNo Always restarts\n\tRestartPolicyRunNo = \"no\"\n\t// RestartPolicyRunAlways Always restarts\n\tRestartPolicyRunAlways = \"always\"\n)\n```\n\n## Types\n\n```go\ntype Container struct {\n\tID          string\n\tStatus      string\n\tImage       string\n\tCommand     string\n\tCPUTime     uint64\n\tMemoryUsage uint64\n\tPidsCurrent uint64\n\tPidsLimit   uint64\n\tConfig      *RuntimeConfig `json:\",omitempty\"`\n\tHostConfig  *HostConfig    `json:\",omitempty\"`\n\tPorts       []Port         `json:\",omitempty\"`\n\tPlatform    string\n\tHealthcheck Healthcheck\n}\n```\nContainer represents a created container\n\n```go\ntype ContainerConfig struct {\n\t// ID uniquely identifies the container\n\tID string\n\t// Image specifies the image reference used for a container\n\tImage string\n\t// Command are the arguments passed to the container's entrypoint\n\tCommand []string\n\t// Ports provide a list of published ports\n\tPorts []Port\n\t// Labels set labels to the container\n\tLabels map[string]string\n\t// Volumes to be mounted\n\tVolumes []string\n\t// Memlimit\n\tMemLimit utils.MemBytes\n\t// CPUlimit\n\tCPULimit float64\n\t// Environment variables\n\tEnvironment []string\n\t// Restart policy condition\n\tRestartPolicyCondition string\n\t// DomainName Container NIS domain name\n\tDomainName string\n\t// AutoRemove sets the container to be removed automatically when stopped\n\tAutoRemove bool\n\t// Healthcheck contains the command and interval of the checks\n\tHealthcheck Healthcheck\n\t// Platform contains the platform information\n\tPlatform *specs.Platform\n}\n```\nContainerConfig contains the configuration data about a container\n\n```go\ntype DeleteRequest struct {\n\tForce bool\n}\n```\nDeleteRequest contains configuration about a delete request\n\n```go\ntype ExecRequest struct {\n\tStdin       io.Reader\n\tStdout      io.Writer\n\tStderr      io.Writer\n\tCommand     string\n\tInteractive bool\n\tTty         bool\n}\n```\nExecRequest contaiens configuration about an exec request\n\n```go\ntype Healthcheck struct {\n\t// Disable disables the check\n\tDisable bool\n\t// Test is the command to be run to check the health of the container\n\tTest []string\n\t// Interval is the period in between the checks\n\tInterval types.Duration\n\t// Retries is the number of attempts before declaring the container as healthy or unhealthy\n\tRetries int\n\t// StartPeriod is the start delay before starting the checks\n\tStartPeriod types.Duration\n\t// Timeout is the timeout in between checks\n\tTimeout types.Duration\n}\n```\nHealthcheck defines the configuration of a healthcheck\n\n```go\ntype HostConfig struct {\n\tRestartPolicy     string\n\tCPUReservation    float64\n\tCPULimit          float64\n\tMemoryReservation uint64\n\tMemoryLimit       uint64\n\tAutoRemove        bool\n}\n```\nHostConfig config of the container host\n\n```go\ntype LogsRequest struct {\n\tFollow bool\n\tTail   string\n\tWidth  int\n\tWriter io.Writer\n}\n```\nLogsRequest contains configuration about a log request\n\n```go\ntype Port struct {\n\t// HostPort is the port number on the host\n\tHostPort uint32\n\t// ContainerPort is the port number inside the container\n\tContainerPort uint32\n\t// Protocol is the protocol of the port mapping\n\tProtocol string\n\t// HostIP is the host ip to use\n\tHostIP string\n}\n```\nPort represents a published port of a container\n\n```go\ntype RuntimeConfig struct {\n\tLabels []string          `json:\",omitempty\"`\n\tEnv    map[string]string `json:\",omitempty\"`\n\t// FQDN is the fqdn to use\n\tFQDN string `json:\"fqdn,omitempty\"`\n}\n```\nRuntimeConfig config of a created container\n\n```go\ntype Service interface {\n\t// List returns all the containers\n\tList(ctx context.Context, all bool) ([]Container, error)\n\t// Start starts a stopped container\n\tStart(ctx context.Context, containerID string) error\n\t// Stop stops the running container\n\tStop(ctx context.Context, containerID string, timeout *uint32) error\n\t// Kill stops the running container\n\tKill(ctx context.Context, containerID string, signal string) error\n\t// Run creates and starts a container\n\tRun(ctx context.Context, config ContainerConfig) error\n\t// Exec executes a command inside a running container\n\tExec(ctx context.Context, containerName string, request ExecRequest) error\n\t// Logs returns all the logs of a container\n\tLogs(ctx context.Context, containerName string, request LogsRequest) error\n\t// Delete removes containers\n\tDelete(ctx context.Context, containerID string, request DeleteRequest) error\n\t// Inspect get a specific container\n\tInspect(ctx context.Context, id string) (Container, error)\n}\n```\nService interacts with the underlying container backend\n\n","path":"github.com/docker/compose-cli/api/containers","name":"containers","synopsis":"","isRedistributable":true}
