containers

package
v1.0.35 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2023 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// RestartPolicyNone Never restarts
	RestartPolicyNone = "none"
	// RestartPolicyAny Always restarts
	RestartPolicyAny = "any"
	// RestartPolicyOnFailure Restarts only on failure
	RestartPolicyOnFailure = "on-failure"

	// RestartPolicyRunNo Always restarts
	RestartPolicyRunNo = "no"
	// RestartPolicyRunAlways Always restarts
	RestartPolicyRunAlways = "always"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container struct {
	ID          string
	Status      string
	Image       string
	Command     string
	CPUTime     uint64
	MemoryUsage uint64
	PidsCurrent uint64
	PidsLimit   uint64
	Config      *RuntimeConfig `json:",omitempty"`
	HostConfig  *HostConfig    `json:",omitempty"`
	Ports       []Port         `json:",omitempty"`
	Platform    string
	Healthcheck Healthcheck
}

Container represents a created container

type ContainerConfig

type ContainerConfig struct {
	// ID uniquely identifies the container
	ID string
	// Image specifies the image reference used for a container
	Image string
	// Command are the arguments passed to the container's entrypoint
	Command []string
	// Ports provide a list of published ports
	Ports []Port
	// Labels set labels to the container
	Labels map[string]string
	// Volumes to be mounted
	Volumes []string
	// Memlimit
	MemLimit utils.MemBytes
	// CPUlimit
	CPULimit float64
	// Environment variables
	Environment []string
	// Restart policy condition
	RestartPolicyCondition string
	// DomainName Container NIS domain name
	DomainName string
	// AutoRemove sets the container to be removed automatically when stopped
	AutoRemove bool
	// Healthcheck contains the command and interval of the checks
	Healthcheck Healthcheck
	// Platform contains the platform information
	Platform *specs.Platform
}

ContainerConfig contains the configuration data about a container

type DeleteRequest

type DeleteRequest struct {
	Force bool
}

DeleteRequest contains configuration about a delete request

type ExecRequest

type ExecRequest struct {
	Stdin       io.Reader
	Stdout      io.Writer
	Stderr      io.Writer
	Command     string
	Interactive bool
	Tty         bool
}

ExecRequest contaiens configuration about an exec request

type Healthcheck added in v1.0.2

type Healthcheck struct {
	// Disable disables the check
	Disable bool
	// Test is the command to be run to check the health of the container
	Test []string
	// Interval is the period in between the checks
	Interval types.Duration
	// Retries is the number of attempts before declaring the container as healthy or unhealthy
	Retries int
	// StartPeriod is the start delay before starting the checks
	StartPeriod types.Duration
	// Timeout is the timeout in between checks
	Timeout types.Duration
}

Healthcheck defines the configuration of a healthcheck

type HostConfig added in v0.1.21

type HostConfig struct {
	RestartPolicy     string
	CPUReservation    float64
	CPULimit          float64
	MemoryReservation uint64
	MemoryLimit       uint64
	AutoRemove        bool
}

HostConfig config of the container host

type LogsRequest

type LogsRequest struct {
	Follow bool
	Tail   string
	Width  int
	Writer io.Writer
}

LogsRequest contains configuration about a log request

type Port

type Port struct {
	// HostPort is the port number on the host
	HostPort uint32
	// ContainerPort is the port number inside the container
	ContainerPort uint32
	// Protocol is the protocol of the port mapping
	Protocol string
	// HostIP is the host ip to use
	HostIP string
}

Port represents a published port of a container

type RuntimeConfig

type RuntimeConfig struct {
	Labels []string          `json:",omitempty"`
	Env    map[string]string `json:",omitempty"`
	// FQDN is the fqdn to use
	FQDN string `json:"fqdn,omitempty"`
}

RuntimeConfig config of a created container

type Service

type Service interface {
	// List returns all the containers
	List(ctx context.Context, all bool) ([]Container, error)
	// Start starts a stopped container
	Start(ctx context.Context, containerID string) error
	// Stop stops the running container
	Stop(ctx context.Context, containerID string, timeout *uint32) error
	// Kill stops the running container
	Kill(ctx context.Context, containerID string, signal string) error
	// Run creates and starts a container
	Run(ctx context.Context, config ContainerConfig) error
	// Exec executes a command inside a running container
	Exec(ctx context.Context, containerName string, request ExecRequest) error
	// Logs returns all the logs of a container
	Logs(ctx context.Context, containerName string, request LogsRequest) error
	// Delete removes containers
	Delete(ctx context.Context, containerID string, request DeleteRequest) error
	// Inspect get a specific container
	Inspect(ctx context.Context, id string) (Container, error)
}

Service interacts with the underlying container backend

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL